Back to Blog
Tutorials
2026-05-19
12 min read

Timeouts, Retries, and Backoff: Stop Making Outages Worse

Design client retry behavior that recovers from transient failures without amplifying an incident.

By API Timing Editorial Team

When an API slows down, clients often respond in the worst possible way: they retry immediately, in lockstep, with no upper bound. That turns a small slowdown into a traffic surge. This article describes how to set timeouts and retries so clients help rather than hurt.

Why timeouts come first

A retry policy without a timeout is not a policy. If a request can hang forever, no retry logic will run. Set two timeouts:

  • Connection timeout: how long to wait for a TCP or TLS connection. This is usually short.
  • Request timeout: the full deadline for the response, including body download.

Choose the request timeout from the user's patience and the endpoint's normal behavior. A 30-second timeout on an interactive endpoint that normally answers in 200 ms will leave users staring at a spinner during an incident. A two-second timeout on a report export will produce false failures. Different endpoints need different deadlines.

Which failures are worth retrying

Retry when the failure is likely to be transient and the request is safe to repeat. Connection resets, timeouts, and some 5xx responses are reasonable candidates. A 400, 401, 403, or 404 will not fix itself with another attempt. A 429 explicitly asks you to slow down.

Idempotency matters. Repeating a GET is harmless. Repeating a payment POST can charge twice unless the server supports an idempotency key. If the operation is not idempotent, either do not retry automatically or require a key that lets the server recognize the repeat.

Backoff and jitter

Backoff means waiting longer between each attempt. A simple pattern is 100 ms, 200 ms, 400 ms, and so on, with a capped maximum. Jitter means adding randomness to the wait. Without jitter, thousands of clients that failed at the same moment retry at the same moment, creating a thundering herd.

A practical client policy looks like this:

  1. Allow at most three attempts for an idempotent request.
  2. Use exponential delays with full jitter: sleep(random(0, base * 2^attempt)).
  3. Cap the base delay and total elapsed time.
  4. Honour Retry-After when the server provides it.
  5. Never retry a non-idempotent write without an idempotency key.

Circuit breakers

If one dependency is failing consistently, continuing to send requests wastes resources on both sides. A circuit breaker tracks recent failures and temporarily stops calls, returning a fast fallback or error. After a cool-down period it allows a small number of probe requests to see whether the dependency recovered.

The breaker should be scoped to the dependency, not to the whole application. A failing recommendation service should not prevent users from reading their own orders.

Observe the client side too

Server dashboards often show a modest error rate while clients are retrying heavily. Track retry counts, retry reasons, and the final outcome after retries. A rising retry rate is an early signal that a dependency is degrading.

Use the API checker to measure the real response time of a failing endpoint from outside your infrastructure. If a request takes longer than your client timeout, that mismatch explains many user-visible failures.

A checklist

  • Set connection and full-request timeouts per endpoint.
  • Retry only transient failures on idempotent calls.
  • Add jitter to exponential backoff.
  • Respect Retry-After.
  • Use idempotency keys for writes.
  • Add circuit breakers around fragile dependencies.
  • Measure retries as a first-class metric.

Good retry behavior is mostly restraint. The goal is to survive a brief failure without amplifying it.

retries
timeouts
backoff
reliability

Related Tools