opyebAPI Bench

Exponential backoff with jitter, without the guesswork

Rate limiting · 6 min read

Backoff is the difference between a client that recovers and a client that keeps a struggling service down. The idea is simple — wait longer after each failure — but the details decide whether a thousand clients retry in lockstep or spread out across the delay window.

The four parameters

An exponential backoff policy has a base delay, a multiplier, a maximum delay and a jitter strategy. With a base of 200 ms and a multiplier of two, the sequence is 200, 400, 800, 1,600 and so on until the cap. The cap matters because without it the fifth retry of a long outage waits minutes and the request is effectively dead while still holding client state.

AttemptDelay without jitterFull jitter rangeEqual jitter range
1200 ms0–200 ms100–200 ms
2400 ms0–400 ms200–400 ms
3800 ms0–800 ms400–800 ms
41,600 ms0–1,600 ms800–1,600 ms

Why jitter is not optional

Without jitter, every client that failed at the same moment retries at the same moment. The result is a synchronised pulse that hits the recovering service exactly when it can least afford it. Full jitter picks a uniform random delay between zero and the computed backoff, which spreads load but occasionally retries immediately. Equal jitter takes half the delay plus a random half, trading a little spread for a guaranteed minimum wait.

Full jitter: delay = random(0, min(cap, base × multipliern)). Equal jitter: delay = d ÷ 2 + random(0, d ÷ 2), where d is the computed backoff.

Respecting the server

If the response carries Retry-After, use it as a floor rather than inventing a delay. A server that says five seconds knows more about its recovery than the client does, and ignoring it creates exactly the load the server is trying to shed. When both a computed backoff and Retry-After exist, wait for the larger of the two.

Bounding the whole request

Backoff parameters are per attempt; you also need a deadline for the logical request. A common structure is a two-second deadline with a 600 ms attempt timeout, so the third attempt cannot start after the budget is spent. Without a total deadline, retries extend the lifetime of doomed requests and consume connections that healthy requests need.

Finally, make the policy visible. Log the attempt number and the chosen delay, and count retries as a metric. A rising retry rate is an early warning of dependency trouble, and it is invisible if the only signal is the final success or failure.

Choosing numbers you can defend

The base delay should be long enough to let a transient condition clear and short enough that the total wall-clock time stays inside the caller's patience. For an interactive request, a base of 100 to 250 milliseconds is common; for a background job, one to two seconds is reasonable because nobody is waiting on the screen. The multiplier of two is conventional because it grows quickly without exploding; a multiplier of three reaches the cap in fewer attempts but leaves less room for a lucky recovery.

The cap should reflect the longest outage you are willing to ride out. If the cap is sixty seconds and the outage lasts two minutes, most clients will have given up by the second attempt, which is fine as long as the failure is reported rather than hidden. What matters is that the cap, the attempt limit and the total deadline agree with each other rather than each being tuned in isolation.

  • Set the total deadline first, then derive the attempt count from it.
  • Prefer 100–250 ms base for user-facing calls.
  • Log the chosen delay so the behaviour can be verified in production.

Open the calculators and put these numbers to work on your own API.

Open API Bench

Frequently asked questions

Should the first retry be immediate?

Usually not. Many failures are transient congestion, and an immediate retry adds load at the worst moment. A base delay of 100 to 200 ms with jitter is a safer default.

What is decorrelated jitter?

A variant where each delay is chosen between the base and three times the previous delay, capped. It spreads retries more aggressively than full jitter and is popular in database clients.

Does backoff apply to 429 only?

No. It applies to any transient failure — 429, 503, 504, connection resets and timeouts — but not to 400, 401, 403 or 404, where retrying the same request cannot succeed.

Sources

Related guides