grpc error: deadline exceeded on unary calls - how to tell server slowness from deadline misconfiguration
Distinguishes gRPC 'deadline exceeded' caused by slow servers from misconfigured deadlines. Use when unary calls fail with deadline errors. Key trigger: the exact 'deadline exceeded' status.
grpc error: deadline exceeded on unary calls - how to tell server slowness from deadline misconfiguration
TL;DR
Deadline exceeded means the client's clock ran out, not necessarily that the server is slow. Compare the deadline value against the server's actual processing time: if the server finishes in 200ms and the deadline is 100ms, the deadline is wrong; if the server takes 10s, the server is slow.
grpc: rpc error: code = DeadlineExceeded desc = context deadline exceededSteps
Read the deadline the client sets: check the context.WithTimeout value on the call path. Expected: You know the budget, e.g. 500ms.
Measure the server's actual handling time from server-side metrics or logs for the same RPC. Expected: You know the cost, e.g. 2s.
Compare: if handling time is comfortably under the deadline and calls still fail, the deadline is not propagating correctly (a retry or a nested context is shrinking it). Expected: The mismatch points at propagation.
If the server is genuinely slower than the deadline, fix the server path or raise the deadline to p99 plus headroom, not to infinity. Expected: Deadlines reflect reality instead of wishes.
Add deadline metrics: record how close calls come to their deadlines so the next misconfiguration pages before users notice. Expected: You see the headroom shrinking in dashboards.
When to use
- unary gRPC calls fail with 'deadline exceeded'
- you need to blame the deadline or the server
- deadlines pass through retries or nested calls
When not to use
- the error is 'unavailable' or 'canceled' (different status codes, different causes)
- streaming calls fail (deadlines interact differently with streams)
- the server never receives the call (that is a network problem)
Tool compatibility
- gRPC (Go, Java, Python, Node)
- unary RPCs
Variant phrasings
- "grpc deadline exceeded unary calls"
- "grpc context deadline exceeded server slow or deadline"
- "grpc deadline exceeded how to tell"
Why it happens
A gRPC deadline is a client-side budget enforced by the client's context. When it fires, all you know is the budget ran out; the server may have been slow, or the budget may have been unrealistic, or an intermediate layer may have shortened it. Only the server's own timing separates the two.
Edge cases
- retries with the same deadline share the remaining budget; a retry storm can burn the whole deadline on attempts
- deadlines propagate through nested calls, so a tight outer deadline fails fast inner calls that would have succeeded
- clock skew between client and server does not affect deadlines; they are measured on the client's clock only
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_qRGmlQq3ofUh9hsGvTUf4w