What is gRPC and what problems does it solve?
Learn what gRPC is, how it uses Protocol Buffers over HTTP/2, and the problems it solves versus REST, with examples, benefits and interview answers.
Expected Interview Answer
gRPC is a high-performance, open-source remote procedure call (RPC) framework that lets a client call methods on a remote server as if they were local functions, using Protocol Buffers over HTTP/2.
It solves the problems of slow, verbose, loosely-typed service communication. By using a strict .proto contract to generate strongly-typed client and server code in many languages, HTTP/2 for multiplexed connections, and compact binary serialization, gRPC gives low latency, small payloads, streaming, and cross-language interoperability that plain JSON-over-HTTP APIs struggle to match at scale.
- Strongly-typed contracts via .proto files
- Compact, fast binary serialization
- HTTP/2 multiplexing and streaming
- Automatic multi-language code generation
- Lower latency and bandwidth than JSON/REST
- Built-in support for deadlines, cancellation and auth
AI Mentor Explanation
gRPC is like a fielding side running perfectly rehearsed set plays: the captain calls a coded signal and every fielder instantly knows their exact position and role. The shared playbook is agreed before the match, so a single short call triggers a fast, coordinated response with no time wasted explaining what to do.
Step-by-Step Explanation
Step 1
Define the contract
Write a .proto file describing services, RPC methods, and request/response message types.
Step 2
Generate code
Run the protoc compiler with the gRPC plugin to produce typed client and server stubs in your target languages.
Step 3
Implement the server
Fill in the generated service interface with your business logic and start a gRPC server.
Step 4
Call from the client
Use the generated stub to call remote methods as if they were local functions.
Step 5
Communicate over HTTP/2
gRPC serializes messages to Protocol Buffers binary and transports them over a multiplexed HTTP/2 connection.
What Interviewer Expects
- A clear definition of RPC and gRPC
- Awareness of Protocol Buffers and .proto contracts
- Knowledge that gRPC runs over HTTP/2
- Understanding of the problems it solves versus REST/JSON
- Mention of cross-language code generation and streaming
Common Mistakes
- Confusing gRPC with a data format instead of an RPC framework
- Saying gRPC uses HTTP/1.1 or plain JSON
- Forgetting the .proto contract drives code generation
- Claiming gRPC is only for microservices and nothing else
- Ignoring browser limitations that require gRPC-Web
Best Answer (HR Friendly)
“gRPC is a modern way for different software services to talk to each other quickly and reliably. You describe the available operations in a shared file, and gRPC generates the code so a program can call another program's functions across the network as easily as calling its own.”
Code Example
syntax = "proto3";
package greet;
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply);
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}Follow-up Questions
- How does gRPC differ from REST?
- What role do Protocol Buffers play in gRPC?
- Why does gRPC require HTTP/2?
- What types of streaming does gRPC support?
- How do you call a gRPC service from a browser?
MCQ Practice
1. What underlying transport protocol does gRPC use by default?
gRPC relies on HTTP/2, which provides multiplexing, streaming and header compression.
2. How does gRPC serialize messages by default?
gRPC uses Protocol Buffers, a compact binary serialization format, by default.
3. What primarily defines a gRPC service contract?
A .proto file declares the services, methods and message types used to generate client and server code.
Flash Cards
What does gRPC stand for? — gRPC Remote Procedure Call, a framework for calling remote methods as if local.
What serialization does gRPC use? — Protocol Buffers, a compact binary format defined in .proto files.
What transport does gRPC use? — HTTP/2, enabling multiplexing, streaming and header compression.
What generates gRPC client/server code? — The protoc compiler with a gRPC plugin, from the .proto contract.