← Lessons

quiz vs the machine

Gold1410

System Design

Request Timeouts and Budgets

Bounding how long a call can wait so slow dependencies do not freeze everything.

5 min read · core · beat Gold to climb

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.

Check yourself

Answer to earn rating on the learn ladder.

1. What problem do timeouts primarily prevent?

2. How should a time budget flow through a chain of calls?