gRPC, real-time APIs and webhooks · senior
gRPC in production: deadlines, retries and load balancing
gRPC waits forever unless you set a deadline, retries multiply load when they stack, and a normal Kubernetes Service balances connections, not calls, so traffic piles on a few pods.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- No deadline means the call waits forever by default. Every client call needs a deadline. Threads blocked on a slow service can make the whole caller stop answering, even requests that do not need that service.
- Deadlines propagate: pass the remaining time to downstream calls. The server must notice cancellation (ctx.Done() in Go, the cancellation listener in Java) and stop work for callers that have gone.
- Retries multiply. A code retry of 3 times and a channel retry policy of 4 attempts can make up to 12 calls per request. Retry only UNAVAILABLE and only for idempotent methods, use backoff with jitter, and use retry budgets or throttling.
- A cluster IP Service balances at layer 4: it picks a pod when a connection opens. A gRPC channel keeps one HTTP/2 connection for a long time, so each caller stays on the pod it first met and new pods get no traffic.
- Quick relief: restart the callers so they reconnect, or set a maximum connection age on the server.
- Proper fixes: client-side balancing with a headless Service (clusterIP: None) so DNS returns every pod and the round_robin policy (many libraries default to pick_first), or a layer 7 proxy that balances each request (Envoy, Linkerd, Istio, a gRPC-aware cloud load balancer).
- Check results with metrics per pod: requests per second and CPU on each pod should be similar.
The red pen
Common traps: mistake → fix
Mistake: Adding more pods spreads gRPC load automatically
Fix: Connections stay on the old pods. Use client-side or layer 7 balancing.
Mistake: Retries make the system more reliable
Fix: Uncontrolled retries multiply load on an already slow service and keep it down after recovery.
Mistake: A server timeout is enough
Fix: The client needs a deadline too, and the server must stop work when the call is cancelled.
Easy to hard
Questions interviewers ask, easy to hard
- What happens to a gRPC call with no deadline?
- Why can retries make an outage longer?
- Why do all gRPC calls from one service go to three of ten pods?
- What is a headless Service and how does it help gRPC?
- A checkout service stayed down for an hour after pricing recovered. List every cause and fix.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.