Why timeouts matter
Without a timeout, a call to a slow dependency can hang indefinitely. Threads and connections pile up waiting, and soon the whole service runs out of resources. A timeout turns a slow failure into a fast, recoverable one.
Set timeouts everywhere
Every network call should have a timeout. A request that has already waited too long is rarely worth finishing because the user has likely given up and the work is now wasted.
The time budget
In a chain of services, the real constraint is the total time budget the caller is willing to wait. Each downstream call must fit inside the remaining budget, not its own private timeout.
- The top request starts with a budget, say one second.
- Each hop subtracts the time it spent and passes the remainder downstream.
- If the remaining budget is near zero, fail fast instead of starting new work.
Key idea
Give every call a timeout and propagate a shrinking time budget down the chain so slow dependencies fail fast instead of exhausting resources.