termEngineering & architecture

Timeout

A limit on how long an operation may wait before the caller stops treating it as in progress.

Download Markdown (.md)

01What it means

A timeout bounds the waiting period for an operation such as a connection, request, lock, or background task. When the limit expires, the waiting component returns or raises a timeout outcome and may cancel remaining work. A timeout does not prove that remote work failed or stopped; its result can be ambiguous.[1][2]

02Why it matters

Without bounded waits, slow dependencies consume connections, threads, memory, and user attention until failures cascade. Timeouts turn latency expectations into resource boundaries and enable fallbacks, cancellation, or recovery, while forcing teams to handle uncertain completion.

03When to use it

Set timeouts on network calls, resource acquisition, and work whose value expires. Base them on the user's or caller's overall deadline and observed latency, leaving budget for any recovery. Very short fixed limits are inappropriate when normal latency varies widely or initialization has distinct behavior.

04How it works

  1. Define the end-to-end deadline from the user's or upstream caller's needs.
  2. Allocate smaller time budgets to connections, attempts, and downstream calls.
  3. Propagate the remaining deadline so nested components do not outlive the request.
  4. Cancel work when possible and release held resources after expiry.
  5. Treat ambiguous write outcomes as potentially completed and recover with idempotency or status checks.
  6. Measure timeout rates and latency distributions, then tune limits from evidence.

05A practical example

Example

A checkout request has a four-second deadline. The payment call receives two seconds, leaving time to return a useful state. If it times out, the service checks the idempotent payment status instead of immediately creating another charge.

06Where it breaks

A timeout only stops waiting; remote work may continue and later commit. Limits that are too short create false failures and extra retries, while limits that are too long consume resources and violate user expectations. One value rarely fits every operation or network path.

Common mistakes

  • Assuming a timeout means the remote operation definitely did not happen.
  • Using library defaults without relating them to an end-to-end deadline.
  • Adding retries whose combined duration exceeds the user's remaining time.
  • Timing only response reads while leaving connection or name resolution unbounded.

07Sources

  1. Timeouts, Retries, and Backoff with JitterAmazon Web Services · Institutional engineering guidanceTimeouts, Retries, and Backoff with Jitter
  2. DeadlinesgRPC · Official technical documentationDeadlines
View saved topics

Start typing to search titles, definitions, categories, and frameworks.