System Design AI

gRPC in System Design Interviews: When to Use It and What to Say

gRPC is a remote-procedure-call framework that lets services talk to each other with a strongly-typed, binary protocol defined by Protocol Buffers. In an interview you can say it provides “efficient, contract-driven RPC over HTTP/2.”

The problem gRPC solves

Most system-design questions involve many services that must exchange data quickly and reliably. Traditional REST/JSON APIs are easy to understand but they incur extra overhead: each request carries a text-based payload, and HTTP/1.1 handles only one request at a time on each TCP connection. When you need sub-millisecond latency, bidirectional streams, or strict type safety, those costs add up.

Concrete example: imagine a real-time recommendation engine that receives a click event, enriches it with user profile data, and writes the result to a streaming analytics pipeline. The click service, user service, and analytics service all need to talk to each other many times per second. With REST, each hop would involve JSON serialization, separate TCP handshakes, and no built-in flow control. gRPC solves this by:

  • Using HTTP/2, which multiplexes many streams over a single connection.
  • Serializing messages with protobuf, which is roughly 5-10× smaller than equivalent JSON.
  • Providing built-in streaming primitives (client, server, and bidirectional).

How gRPC works – step by step

  1. Define the contract – Write a .proto file that declares services, RPC methods, request and response messages. Example:
proto
 service ClickService {
 rpc RecordClick(ClickRequest) returns (ClickResponse);
 }
 message ClickRequest { string user_id = 1; string item_id = 2; }
 message ClickResponse { bool ok = 1; }
  1. Generate code – The protobuf compiler (protoc) creates client and server stubs for your language (e.g., Go, Java, Python).
  2. Start a server – Implement the service methods and bind the server to a port. Under the hood the server creates an HTTP/2 listener.
  3. Create a client – The client uses the stub to invoke RecordClick. The call is serialized to protobuf, framed into HTTP/2 frames, and sent over the persistent connection.
  4. Transport – HTTP/2 handles flow control, header compression, and multiplexing. If the method is defined as a stream, the client and server can exchange messages without closing the stream.
  5. Error handling – gRPC returns its own status codes (e.g., UNAVAILABLE, DEADLINE_EXCEEDED) in HTTP/2 trailers at the end of the response, so a client can tell which failures are safe to retry.

Worked mini-example: a logging service that streams log entries from many microservices.

proto
service LogStreamer {
 rpc StreamLogs(stream LogEntry) returns (stream Ack);
}
message LogEntry { string source = 1; string line = 2; }
message Ack { int64 received = 1; }

Each microservice opens a single HTTP/2 connection to the LogStreamer, then continuously pushes LogEntry messages. The server replies with an Ack for every batch, keeping the round-trip latency low.

Classic design questions where gRPC shows up

Design QuestionWhere gRPC fitsReason for choosing it
Real-time chat / messagingBetween chat server nodes and the presence serviceNeeds bidirectional streaming and low latency
Video streaming platform (ingest pipeline)Between ingest workers and transcoding serviceHigh throughput, binary payload, flow control
Distributed tracing collectorFrom application agents to the collector backendStrong typing for trace IDs, streaming of spans

In each case the interviewer will likely ask you to pick a communication protocol for service-to-service calls. Mentioning gRPC signals that you understand the need for efficient binary RPC and HTTP/2 features.

Trade-offs and the alternative interviewers will probe

AspectgRPCTypical alternative (REST/JSON)
LatencyLow – binary frames, connection reuseHigher – text payload, one request at a time per HTTP/1.1 connection
StreamingNative client-/server-side streamsRequires custom WebSocket or SSE setup
ToolingStrong code generation, IDE supportSimple curl or browser testing
Browser supportLimited – needs gRPC-Web proxyNative – works directly in browsers
VersioningSchema evolution via protobuf fieldsManual contract negotiation
ObservabilityBuilt-in status codes, interceptorsCustom error handling

Key trade-off: gRPC gives you performance and type safety at the cost of tighter coupling to protobuf schemas and a steeper learning curve. Interviewers often follow up with “What if the client is a web browser?” – the answer is to use gRPC-Web (a thin proxy) or fall back to REST.

A 30-second spoken pitch

“gRPC is a high-performance RPC framework that uses Protocol Buffers over HTTP/2. It gives us tiny binary messages, built-in streaming, and strong typing, which is ideal for low-latency microservice communication like real-time analytics pipelines. The trade-off is that we need a protobuf contract and it isn’t natively supported in browsers, so we’d use gRPC-Web or fall back to REST when a browser client is required.”

Common mistakes candidates make

  • Treating gRPC as a silver bullet – Claiming it solves every scaling problem ignores the operational overhead of managing protobuf schemas and the need for HTTP/2 load balancers.
  • Skipping the schema discussion – Interviewers expect you to mention how you version messages (adding optional fields, deprecating old ones) and how the contract is shared across teams.
  • Over-promising latency – Saying “gRPC gives sub-millisecond latency” without qualifying that it depends on network conditions and payload size.
  • Forgetting browser constraints – Not addressing how a front-end would call the service, or assuming gRPC works directly in a browser.
  • Mixing up streaming semantics – Confusing client-side streaming with bidirectional streaming, or not explaining back-pressure handling.

How to practice this

  1. Pick a classic interview problem (e.g., real-time chat) and write a small .proto file for the core services.
  2. Use protoc to generate stubs in your favorite language and build a minimal client-server pair that exchanges a few messages.
  3. Open a System Design AI canvas, sketch the service diagram, and annotate where gRPC sits, then run the AI coach to get feedback on your explanation.

Questions people ask

When should I choose gRPC over REST?

Pick gRPC when you need low latency, binary payloads, and streaming between backend services. If you need direct browser support or the simplest client, REST/JSON is usually easier.

Does gRPC work with existing load balancers?

Most modern load balancers (AWS ALB, NGINX, etc.) support HTTP/2 and can terminate gRPC traffic. You just need to enable HTTP/2 and configure health checks for the gRPC endpoints.

Can I use gRPC with multiple programming languages?

Yes. The protobuf contract is language-agnostic, and the protoc compiler can generate client and server stubs for dozens of languages, making it suitable for polyglot microservice stacks.

What is the biggest operational pitfall of gRPC?

Managing protobuf schema evolution across many teams. Without careful versioning, a change in one service can break others that haven’t regenerated their code.