gRPC · Concept
The four kinds of gRPC call
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
gRPC has unary calls and three kinds of streaming. Explain each one with a real example from a delivery app, and tell me what happens on the wire.
Then
Follow-ups the interviewer asks next
- What does HTTP/2 give gRPC that HTTP/1.1 can't?
- How does an error come back in a stream?
- The rider app streams location points faster than the server can save them. What happens?
- Can a load balancer move a long stream to a new pod?
- What are metadata and status codes?
- When would you avoid streaming?
The answer
What a strong answer covers
- Unary: one request, one response (
GetOrder). Server streaming: one request, many responses (WatchOrderStatussends changes until delivery). Client streaming: many requests, one response (the rider app sends location points, gets one summary). Bidirectional: both sides send on one stream independently (dispatch and rider exchanging offers and acks). - On the wire: each call is an HTTP/2 stream on a long-lived connection; messages are length-prefixed protobuf frames; the call ends with trailers carrying
grpc-statusandgrpc-message. Many calls share one connection (multiplexing), with compressed headers. - Errors: a status code (
OK,INVALID_ARGUMENT,NOT_FOUND,DEADLINE_EXCEEDED,UNAVAILABLE,RESOURCE_EXHAUSTED, …), optionally with rich details. In a stream the status comes at the end and closes it. - Back-pressure: HTTP/2 flow-control windows make a fast writer wait for a slow reader (some APIs buffer instead, so watch memory).
- A stream can't be load-balanced once it has started; servers set a maximum connection age and clients reconnect and resume from the last event they saw.
- Metadata: key-value headers for the auth token, request id and trace context.
- Avoid streaming when unary works: harder to debug, balance and retry. gRPC's docs note that in Python, streaming calls are much slower than unary ones.
The red pen
Common traps
Avoid:"gRPC is just faster REST"; not knowing that the status arrives in trailers; streams for everything.
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.