The idea
A request can cross several services before returning a response. Independent generous timeouts at every hop can make the total wait much longer than the caller expects. A deadline makes the remaining budget visible along the path.
Design choice
Start with a user-facing deadline and reserve time for the final response. Propagate the remaining budget to downstream calls. Stop work that no longer has a waiting caller where cancellation is safe; do not mistake a timeout for proof that a write failed.
Worked example
A dashboard has a two-second response budget. After one slow dependency consumes most of it, the service omits an optional comparison panel instead of starting another full two-second call.
Before you ship
- Define the total deadline.
- Propagate cancellation deliberately.
- Test the outcome of a timed-out write.
Examples are illustrative. Adapt the checks to your own environment.