Timeout Context in Request Headers
What you'll learn: How services communicate timeout information to each other using HTTP headers or metadata so the entire request chain respects the original deadline.
The Problem
When a client makes a request with a 5-second timeout, it calls Service A, which calls Service B, which calls Service C. Without coordination, Service C might spend 4 seconds processing a request that Service A already gave up on 3 seconds ago—wasting compute resources on abandoned work.
Passing Timeout Context
The solution is to propagate timeout information through the call chain using request headers or metadata. The original caller includes its deadline or remaining time budget in the request, and each downstream service reads and honors it.
Common approaches:
X-Timeout-MSheader: Remaining milliseconds in the timeout budgetX-Deadlineheader: Absolute timestamp (e.g., Unix milliseconds) when work must complete- gRPC context deadlines: Built-in metadata that automatically propagates
Each service in the chain:
- Reads the timeout context from the incoming request
- Sets its own internal timeout to be less than the remaining budget (leaving buffer for network/processing)
- Passes the updated context to any downstream calls
The Coordination Benefit
This prevents the "zombie request" problem where downstream services waste CPU on work the caller has already abandoned. If Service A times out at 5s, Service B (which reads the header) knows to stop processing after 4.5s, and Service C after 4s—everyone coordinates around the same deadline.
Key Takeaway: Timeout context in request headers allows distributed services to coordinate around a shared deadline, preventing wasted work on requests the client has already abandoned.