When interviewers ask about gRPC they want to see that you understand both the what and the why. A strong answer is short, concrete, and shows you can map the technology to real‑world problems.
What gRPC Is
gRPC (pronounced gee‑RPC) is an open‑source remote‑procedure‑call framework originally created at Google. It lets a client invoke methods on a server as if they were local functions, while handling transport, serialization, and code generation for you.
How It Works Under the Hood
- Interface Definition – You write a
.protofile that describes services, RPC methods, and message schemas using Protocol Buffers (protobuf). The file is language‑agnostic. - Code Generation – The
protoccompiler, together with language‑specific plugins, generates client and server stubs. These stubs expose strongly‑typed methods matching the protobuf definitions. - Transport Layer – gRPC uses HTTP/2 as its transport. HTTP/2 provides multiplexed streams, binary framing, flow control, and built‑in support for TLS.
- Serialization – Messages are serialized to the compact binary protobuf format, which is much smaller and faster to parse than JSON or XML.
- Call Types – gRPC supports four interaction patterns:
- Unary (single request, single response)
- Server streaming (single request, stream of responses)
- Client streaming (stream of requests, single response)
- Bidirectional streaming (both sides stream)
These patterns map directly to use cases like file download, log aggregation, or real‑time chat.
Trade‑offs to Discuss
| Aspect | gRPC Advantage | gRPC Limitation |
|---|---|---|
| Performance | Binary protobuf + HTTP/2 → low latency, high throughput | Requires HTTP/2 support; older proxies may block it |
| Tooling | Automatic stub generation for >10 languages | Learning curve for protobuf syntax and build pipelines |
| Interoperability | Strong typing reduces bugs | Not human‑readable; debugging raw payloads needs tooling |
| Streaming | Built‑in streaming semantics | Streaming APIs can be harder to version than simple REST endpoints |
| Browser Support | Works via gRPC‑Web bridge | Direct browser use needs a proxy; adds complexity |
When answering, pick the trade‑offs most relevant to the job description. For a backend role, emphasize performance and streaming; for a product‑focused role, note the tighter coupling to protobuf and the need for generated code.
A Concrete Example
Imagine you are building a microservice that processes uploaded images. The client uploads a large file, the server runs a series of transformations, and streams back progress updates.
syntax = "proto3";
package image;
service ImageProcessor {
// Client streams chunks, server streams progress updates.
rpc Transform(stream ImageChunk) returns (stream TransformStatus);
}
message ImageChunk {
bytes data = 1;
int32 sequence = 2;
}
message TransformStatus {
string step = 1; // e.g., "resize", "compress"
float percent = 2; // 0.0 – 100.0
}
The generated stubs let the client call Transform() and write ImageChunk messages while reading TransformStatus messages as they arrive. The binary payload keeps network usage low, and HTTP/2 multiplexing allows many such streams to share a single TCP connection.
Typical Interview Questions
| Question | What the interviewer is probing |
|---|---|
| “Can you describe the gRPC call lifecycle?” | Understanding of protobuf definition, stub generation, and HTTP/2 framing. |
| “When would you choose gRPC over REST?” | Ability to weigh performance, streaming needs, and ecosystem constraints. |
| “How does gRPC handle versioning?” | Knowledge of protobuf’s backward‑compatible field numbering and optional fields. |
| “What are the security considerations?” | Awareness that gRPC defaults to TLS over HTTP/2 and that you can add per‑method authentication metadata. |
| “What challenges have you faced with gRPC in production?” | Real‑world experience with load balancers, observability, or client‑side streaming limits. |
Answering these with concrete anecdotes (e.g., “We ran into a load‑balancer that stripped HTTP/2 headers, so we added a gRPC‑Web proxy”) shows depth.
A 60‑Second Spoken Answer
"gRPC is a high‑performance RPC framework built on HTTP/2 and Protocol Buffers. You define your service in a
.protofile, thenprotocgenerates typed client and server code for many languages. Under the hood, gRPC uses HTTP/2 streams, so you get multiplexing, flow control, and built‑in TLS, while protobuf gives you a compact binary payload. The trade‑offs are speed and built‑in streaming versus the need for protobuf tooling and less human‑readable traffic. For example, in a recent image‑processing service we streamed upload chunks from the client and streamed back progress updates, cutting latency by half compared to a REST polling approach. I’d pick gRPC when low latency, streaming, or strong typing are critical, and I’d avoid it if the ecosystem relies heavily on simple JSON APIs or if you need direct browser support without a proxy."
Practicing this answer aloud—perhaps with Call Assistant’s interview rehearsal mode—helps you keep the pacing under a minute and ensures you stay on topic.
How to Practice This
- Write the protobuf – Draft a simple
.protofile for a service you care about (e.g., a todo list). Generate stubs in your preferred language and run a minimal client‑server demo. - Record a 60‑second pitch – Use a voice recorder or Call Assistant to deliver the spoken answer. Listen back and trim any filler.
- Mock Q&A – Pair with a colleague or use an interview‑bot to ask the typical questions above. Focus on linking each answer to a concrete experience from your resume.
FAQ
Q: Do I need to use HTTP/2 for gRPC? A: Yes, gRPC relies on HTTP/2 for multiplexed streams and binary framing. Some deployments use a gRPC‑Web proxy to bridge browsers that only support HTTP/1.1.
Q: Can gRPC work with existing REST APIs? A: You can run both side‑by‑side, but they use different serialization (protobuf vs. JSON). A gateway can translate between them if you need to expose a REST façade.
Q: How does protobuf handle backward compatibility? A: Adding new fields with unique numbers is safe; older clients will ignore unknown fields. Removing or renumbering fields breaks compatibility, so you keep field numbers stable.
Q: What monitoring tools are common for gRPC? A: OpenTelemetry, Prometheus exporters, and language‑specific interceptors let you collect latency, error rates, and stream metrics without modifying business logic.
Frequently asked questions
Do I need to use HTTP/2 for gRPC?
Yes, gRPC is built on HTTP/2, which provides multiplexed streams, binary framing, and built‑in TLS. Without HTTP/2 you lose the core performance and streaming benefits.
Can gRPC coexist with existing REST services?
Absolutely. You can run gRPC and REST side‑by‑side, using a gateway or proxy to translate between protobuf and JSON when you need to expose a REST façade.
How does protobuf ensure backward compatibility?
Protobuf is designed for safe evolution: you can add new fields with new tag numbers, and older clients will simply ignore them. Changing or reusing tag numbers can break compatibility, so keep numbers stable.
What observability tools work with gRPC?
Common choices include OpenTelemetry, Prometheus exporters, and language‑specific interceptors that expose latency, error rates, and stream metrics without touching business code.
#concept#gRPC#interview#backend#performance