What it is
Backoff is the waiting time between retry attempts. With exponential backoff the wait grows by a constant factor (usually doubling) after every failure, up to a cap. Jitter adds randomness to each wait so that clients that failed at the same moment do not retry at the same moment. Together they are the standard way to schedule retries, reconnects and polling loops.
Why it exists
Failures are often correlated: a server restarts and drops every connection at once, a deploy cycles a fleet, a network partition heals. Thousands of clients then experience the failure within the same millisecond. If each of them retries after the same fixed delay, they arrive together again, as a pulse, and a pulse can be large enough to knock the recovering service over, which produces the next synchronised failure. Short fixed delays have a second problem: they burn through all attempts in a fraction of a second, long before a typical outage is over, while keeping the dead service busy rejecting requests.
How it works
Exponential backoff. The wait before retry n is base × 2^(n−1), truncated at a maximum: 100 ms, 200 ms, 400 ms, 800 ms … up to, say, 10 s. Each failure halves the rate at which a client knocks, so a service that is down sees the retry pressure fade instead of staying constant, and a client’s attempts cover a longer stretch of time, long enough to outlast a short outage.
Jitter. Exponential backoff alone keeps synchronised clients synchronised: everyone who failed at time t retries at t + 100 ms, t + 300 ms, t + 700 ms, together. Jitter randomises each wait:
- Full jitter:
delay = random(0, backoff). Spreads clients uniformly over the whole interval; the expected wait is half the backoff. - Equal jitter:
delay = backoff / 2 + random(0, backoff / 2). Guarantees some minimum wait, spreads a little less. - Decorrelated jitter:
delay = min(cap, random(base, previous × 3)). Each wait depends on the previous one rather than on the attempt number.
AWS’s published analysis of these variants found full and decorrelated jitter clearly better than no jitter for contended workloads, and full jitter is the variant many client SDKs implement.
Limits. A cap on the single wait (without one, the tenth wait from 200 ms would be about 100 s), a maximum number of attempts, and an overall deadline that the whole retry sequence must fit into. When the limits are reached the call fails, ideally into a fallback, and a circuit breaker can take over.
Server hints. If the server sends Retry-After (with 429 or 503), use it as the minimum wait, still with jitter added, so many clients do not all return at the advertised second.
When to use it
- Every automatic retry of a remote call.
- Reconnect loops: WebSocket, database, message-broker and cache clients after a disconnect.
- Polling: job status, leader election, lock acquisition.
- Scheduled jobs on many machines: add a random offset so a fleet does not run "every minute at :00" in unison.
When not to
- As the only protection against overload: backoff spreads retries, it does not reduce how many are sent. Add a retry budget or a circuit breaker.
- For interactive actions where the user is waiting and the remaining deadline is shorter than the next backoff; fail and show the error instead.
- With a very large cap on interactive paths: a 60 s wait is fine for a background sync, not for a checkout button.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| Fixed delay | Simple, predictable | Synchronised pulses; gives up quickly or keeps knocking at the same rate |
| Exponential, no jitter | Falling pressure, covers longer outages | Correlated clients stay in lockstep |
| Full jitter | Best spread, simple | Some retries happen almost immediately; average wait is shorter, so attempts end sooner |
| Equal jitter | A guaranteed minimum wait | Less spread than full jitter |
| Higher cap | Survives longer outages | Longer worst-case waits for the user |
| More attempts | More chances to succeed | More load during incidents; longer before a clear failure |
Alternatives
- Retry budgets limit the number of retries rather than their timing.
- Circuit breakers stop retrying entirely while a dependency is failing.
- Server-driven backoff:
Retry-After, or a gateway that sheds load with explicit retry advice. - Queue-based retries: put failed work on a delay queue so the timing is controlled centrally.
- Token-bucket rate limits on the client cap the request rate during reconnect storms.
Failure modes
- Thundering herd on recovery: a fleet of clients without jitter reconnects in one pulse the moment a service comes back.
- No cap: waits grow to minutes or hours; clients look hung.
- Jitter too small (±10%): clients stay clustered.
- Backoff per thread, not per client: many threads in one process each back off independently and still flood the service.
- Backoff reset on every success at low traffic: a single lucky call resets the delay and the client immediately returns to aggressive retrying.
- Retry backlog after a long outage: pending retries plus new traffic arrive together at the recovered service; the lesson’s last step shows a mild version.
In production
Use the retry helpers of your SDK or resilience library (AWS SDKs, Google client libraries, gRPC retry policies, Polly, Resilience4j, Envoy) and check that jitter is enabled; some libraries default to none. Typical values for synchronous calls: base 50–200 ms, cap 1–10 s, 2–4 attempts, inside an overall deadline. For background reconnects: base 1 s, cap 30–60 s, unlimited attempts with jitter. Honour Retry-After. Watch for pulses in request-rate graphs with sub-second resolution after deploys and restarts; a sawtooth is the signature of missing jitter.
Common misconceptions
- "Exponential backoff prevents thundering herds." Without jitter it only spaces the herd’s visits further apart.
- "Jitter makes retries slower." Full jitter makes the average wait shorter than plain exponential backoff; it makes the arrivals more even.
- "Backoff reduces the number of retries." With an attempt limit, every retry is still eventually sent; backoff changes when.
- "A small random offset is enough." The spread has to be comparable to the backoff itself to break the synchronisation.
Interview angle
Whenever you say "and the client retries", add "with exponential backoff and jitter, capped, within a deadline". Be ready to explain why jitter matters with the restart example, to write the formula random(0, min(cap, base × 2^attempt)), and to say that backoff spreads load while budgets and breakers limit it. Mentioning reconnect storms (WebSocket or cache clients after a failover) shows you have seen the problem outside of HTTP retries.
Model assumptions
The simulation is a simplified model, not a benchmark. Clients send 60 requests per second (Poisson) to an API with 8 workers, an 80 ms mean service time (lognormal, cv 0.3) and room for 40 waiting requests; each hop takes 30 ms. Every step replays the same incident: the API is 3× slower from 0 s, so its queue fills; at 1.5 s it goes down, failing everything inside it at the same instant; it is back, healthy, at 3 s (at 7.5 s in the last incident step). Retries use the engine’s retry policy: up to 6 attempts, a base delay of 200 ms that doubles up to a 1.6 s cap (or a fixed 200 ms), with no jitter or full jitter; a retry starts when the client hears of the failure. There are no client timeouts. Numbers show behaviour and orders of magnitude only.