Articles
gRPC Interview Questions for Backend Engineers: Protobuf, Streaming, Deadlines, and Retries
Practice gRPC interview questions on Protobuf, streaming, deadlines, retries, flow control, errors, security, and production trade-offs.
A gRPC service can look perfect in a local demo and still fail badly in production. A slow consumer can stall a stream, a retry can duplicate a payment, and a reused Protobuf tag can silently corrupt meaning across versions.
This guide covers the gRPC interview questions backend engineers are most likely to face, with concise answers on Protobuf, streaming, deadlines, retries, flow control, errors, security, and observability. The goal is not to memorize definitions. It is to show how you reason about a typed RPC when networks, deployments, and partial failures get involved.
A senior gRPC answer connects the contract, stream behavior, time budget, and failure policy.
Quick Verdict: What a Strong gRPC Interview Answer Includes
A strong candidate does not stop at "gRPC uses Protobuf and HTTP/2." They explain what the API promises, what happens under version skew, how work stops after a deadline, and which failures are actually safe to retry.
| # | Senior answer should connect |
|---|---|
| 1 | Contract: service methods, message schemas, compatibility, and semantics |
| 2 | Stream: ordering, flow control, buffering, cancellation, and recovery |
| 3 | Time budget: client deadline, downstream propagation, and useful work |
| 4 | Failure policy: status codes, idempotency, bounded retries, and observability |
gRPC Fundamentals Interview Questions
1. When would you choose gRPC over REST?
Choose gRPC when a typed contract, generated clients, efficient binary messages, or streaming materially improves service-to-service communication. It is especially useful when several teams or languages must share one versioned interface.
Do not claim it is always faster or always better. REST and JSON are often easier for public APIs, browsers, manual inspection, caching infrastructure, and third-party integrations. A senior answer starts with the consumers and operating environment, then chooses the protocol.
2. What happens during a unary gRPC call?
The client calls a generated stub with a request, metadata, and ideally a deadline. The server receives the method and call context, runs the handler, then returns one response plus a final status and optional trailing metadata. The client considers the call complete only after it receives that outcome.
This matters because the client and server can disagree. The server may finish a state change while the response arrives after the client's deadline, so DEADLINE_EXCEEDED does not prove that nothing happened.
3. How should channels and stubs be managed?
Reuse channels and stubs instead of creating a new connection for every request. A channel owns connection state and can carry multiple RPCs, while repeated setup adds latency and resource cost.
Still, one channel is not infinitely elastic. HTTP/2 connections have concurrent-stream limits, and long-lived RPCs can create queueing. Add channels only after measurement shows contention, not as a reflex.
Protobuf Interview Questions
4. How do you evolve a Protobuf schema safely?
Adding a new field is binary wire-safe because old readers treat it as unknown and new readers can handle old messages without it. When removing a field, reserve its number and usually its name so nobody reuses it later.
Plan for version skew because clients and servers do not deploy atomically. Also distinguish binary compatibility from application behavior: a wire-safe change can still break an exhaustive switch, validation rule, or business assumption.
5. Which Protobuf changes are dangerous?
Never reuse a field number or change the number of an existing field. Avoid changing field types, moving fields into an existing oneof, or changing semantics while keeping the same schema shape.
Some numeric type changes are technically wire-compatible but can truncate values during a mixed-version rollout. "Parses successfully" is a much lower bar than "preserves meaning."
6. Why does field presence matter?
With an implicit scalar field, a consumer may not be able to distinguish "not supplied" from "supplied with the zero value." In APIs where that distinction changes behavior, use explicit presence, such as optional, and define what absence means.
This often appears in patch APIs. Setting max_attempts to zero may be different from leaving it unchanged, so the contract needs a presence signal rather than a guessed default.
7. How should enums be designed for compatibility?
Use an UNSPECIFIED value at number zero, and make it non-semantic. New enum values are binary wire-safe, but old application code may still mishandle them or fail an exhaustive switch.
A robust consumer has an unknown-value strategy. During rollout, monitor both serialization compatibility and the business behavior of older clients.
Streaming, Ordering, and Flow Control Questions
8. What are the four gRPC RPC types?
Unary is one request and one response. Server streaming returns many responses, client streaming accepts many requests and returns one response, and bidirectional streaming lets both sides send independent message streams.
Choose streaming for a genuinely long-lived logical flow, not because it sounds advanced. Streams reduce repeated RPC setup, but they complicate recovery, load balancing, debugging, and resource management.
9. What ordering does bidirectional streaming guarantee?
gRPC preserves message order within each direction of one RPC. The client-to-server and server-to-client streams operate independently, so there is no automatic global order across both directions.
It also does not create exactly-once business processing. If reconnects matter, add application sequence numbers, acknowledgements, deduplication, and a resume protocol.
10. How do flow control and backpressure work?
Flow control prevents a fast sender from overwhelming a slower receiver and applies to streaming RPCs. A write can wait for capacity, and handing a message to the gRPC framework does not mean the bytes have already crossed the network.
At the application layer, keep queues bounded and decide what a slow consumer should cause: wait, drop an allowed update, spill elsewhere, or close the stream. With synchronous or manual flow control, both sides writing heavily without reading can deadlock.
11. How do you recover a long-lived stream?
Assume the stream can end after either side has processed only part of the conversation. Reconnect with a stable stream identity, the last acknowledged sequence, bounded backoff, and rules for replaying or deduplicating messages.
A stream cannot be rebalanced after it has started, so reconnect behavior also affects traffic distribution. Keepalive can detect a broken connection, but it is not a substitute for service health or application-level progress.
Deadlines, Cancellation, and Retry Questions
12. What is the difference between a timeout and a deadline?
A timeout is a maximum duration; a deadline is the point in time after which the client will no longer wait. Language APIs expose one or the other, but the design question is the same: how much end-to-end time is this operation allowed?
gRPC does not set a deadline by default, so a client can otherwise wait effectively forever. Pick a realistic value from the user journey, network and processing distributions, then validate it under load.
13. How should deadlines and cancellation propagate?
When a server calls downstream services, it should propagate the remaining time budget rather than start a fresh full timeout. Supporting gRPC implementations convert the deadline to a timeout and subtract elapsed time, which helps avoid clock-skew problems.
When the deadline expires, the server handler must stop its own spawned work and cancel downstream calls. Cancellation is a signal, not a transaction rollback; changes already committed remain committed.
14. Why is idempotency essential before enabling retries?
A network failure can hide the outcome of an operation. Retrying a read is usually straightforward, but retrying ChargeCard or CreateOrder can duplicate side effects unless the request carries an idempotency key or the server has an equivalent deduplication rule.
Define idempotency at the business-operation level, store the result against the key, and return the original outcome on replay. A method name or status code cannot make an unsafe operation safe.
15. How does gRPC retry work?
Transparent retries cover narrow low-level failures where gRPC can determine that application logic did not process the RPC. Broader retries require a per-method policy with attempt limits, exponential backoff, and explicit retryable status codes.
Once response headers are received, the RPC is committed and gRPC stops retrying it. The retry policy must also fit inside the original deadline; four attempts are useless if the first three consume the entire time budget.
16. How do you prevent a retry storm?
Use bounded attempts, exponential backoff with jitter, retry throttling or server pushback, and a deadline that caps the total work. Retry only transient failures for operations that are safe to repeat.
Measure attempts separately from logical calls. If latency rises while attempt count rises faster than call count, retries may be amplifying an overloaded dependency rather than improving availability.
Production gRPC Interview Questions
17. How do you choose gRPC status codes?
Use the most specific code the caller can act on. INVALID_ARGUMENT means the input is bad regardless of system state; FAILED_PRECONDITION means the operation is blocked by current state; UNAVAILABLE signals temporary service unavailability.
Do not turn status codes into a universal retry table. Retry safety depends on the operation, whether the request may have been processed, the caller's deadline, and any server guidance.
18. How do load balancing and long-lived streams interact?
The channel resolves a target and applies a load-balancing policy when selecting a backend for a new RPC. Once a long-lived stream starts, it remains attached to that backend until it ends.
That can create uneven load during deployments or traffic shifts. Design graceful draining, bounded stream lifetimes where appropriate, reconnect jitter, and enough capacity for clients that reconnect together.
19. How would you secure a gRPC service?
Use TLS for server authentication and encryption, with mutual TLS when client identity belongs at the transport layer. Pass per-call credentials through supported credential and metadata mechanisms, then enforce authorization at the method and resource level.
Keep metadata small, do not log secrets, validate every message, and separate identity from permission. An authenticated caller is not automatically authorized to access every resource in a request.
20. What would you monitor in production?
Track end-to-end call latency and status, but also per-attempt latency, retry count, retry delay, message size, cancellations, and deadline failures. Long-lived streams additionally need active-stream count, message throughput, reconnects, age, and stalled-consumer signals.
Trace the full call chain with method and target attributes, while controlling cardinality. The key distinction is one user-visible call may contain several transport attempts, and your dashboards should make that amplification visible.
Trace one call from typed request to final status, including the remaining deadline and every retry attempt.
Worked Scenario: Checkout Calls Inventory and Payment
Suppose a checkout client sets an 800 ms deadline. The checkout service spends 120 ms validating the cart, then calls inventory and payment. It should pass each downstream call the remaining budget, with a small safety margin, instead of giving each dependency another 800 ms.
An inventory availability read may allow one bounded retry on UNAVAILABLE. A payment charge should carry an idempotency key and provide a way to retrieve the prior outcome, because a timeout can occur after the charge commits but before the response arrives.
If the client cancels, checkout should stop pending work and propagate cancellation. It should not pretend that already committed inventory or payment changes were rolled back; those require explicit compensation or reconciliation.
What Interviewers Are Actually Scoring
Junior answers name features. They know Protobuf, HTTP/2, and four RPC types. Mid-level answers explain mechanics. They can describe deadlines, status codes, and flow control.
Senior answers connect mechanics to failure boundaries. They ask whether a write is idempotent, what happens during version skew, how cancellation reaches downstream work, and how the team will detect retry amplification.
Backend interviews also test communication and ownership, so include behavioral interview practice in your final loop.
A Five-Step Framework for Answering Any gRPC Scenario
1. Define the contract. State the RPC type, request and response semantics, compatibility rules, and whether the operation changes state.
2. Describe the lifecycle. Trace metadata, messages, final status, ordering, and the point at which the caller sees completion.
3. Budget the time. Set the end-to-end deadline, propagate the remaining budget, and explain how cancellation stops useful work.
4. Bound failure. Classify errors, prove idempotency before retrying, add backoff and jitter, and define stream recovery.
5. Make it operable. Cover load balancing, security, rollout compatibility, metrics, traces, and the test that would falsify your design.
Frequently Asked Questions
What should I study first for a gRPC interview?
Start with the four RPC types and a unary call lifecycle. Then learn Protobuf evolution, deadlines and cancellation, flow control, idempotent retries, status codes, and production observability. Practice by tracing one concrete request across multiple services instead of studying each feature in isolation.
Does gRPC guarantee exactly-once delivery?
No. gRPC preserves message order within an individual stream, but retries, reconnects, and ambiguous network failures can still produce duplicate business operations. Exactly-once behavior requires application design such as idempotency keys, sequence numbers, durable deduplication, acknowledgements, or transactional boundaries.
Can a bidirectional stream be retried automatically?
Do not assume it can be replayed safely after application data has flowed. A production design usually needs an application-level reconnect and resume protocol with stream identity, last acknowledged sequence, replay rules, and deduplication. The safe behavior depends on what each message means.
Which gRPC status codes should be retried?
There is no universal list. UNAVAILABLE is commonly considered for bounded retries, but only when the operation is safe to repeat and the deadline permits another attempt. Validation, permission, and precondition failures normally require a caller or state change, not immediate repetition.
Is gRPC always better than REST for microservices?
No. gRPC is strong for typed internal APIs, generated clients, and streaming. REST may be simpler for browser clients, public APIs, debugging, caching, and broad third-party compatibility. The best interview answer compares consumers, traffic shape, tooling, failure behavior, and organizational cost.
Final Takeaway
The best gRPC interview answers treat RPC as a distributed-systems boundary, not a local function call. Protect the Protobuf contract, control stream pressure, carry one deadline through the call chain, and retry only work you can prove is safe.
Official Sources
gRPC Core Concepts covers RPC types, ordering, metadata, deadlines, and lifecycle. gRPC Deadlines explains explicit deadlines, propagation, and cancellation. gRPC Retry documents transparent retry, configured policies, backoff, jitter, throttling, and per-attempt metrics.
gRPC Flow Control covers streaming backpressure and deadlock risk. Protocol Buffers Best Practices and the Proto3 Language Guide cover tag reuse, reserved fields, explicit presence, enums, unknown fields, and schema compatibility.
gRPC Performance Best Practices, Status Codes, Keepalive, Authentication, and OpenTelemetry Metrics support the production guidance in this article.