Home › Blog › Retry strategies, backoff and jitter

Retry strategies, backoff and jitter

The short answer: retry only what is safe and likely to succeed on a second attempt, back off exponentially, add randomness, and cap the total amount of retrying the system is allowed to do. The last point is the one most designs omit, and it is the one that turns a partial outage into a full one.

What should and should not be retried

ConditionRetry?Why
Connection timeout, connection resetYesLikely transient; request may not have been processed
HTTP 429, 503Yes, respect Retry-AfterThe server is explicitly asking you to back off
HTTP 500 on a non-idempotent writeOnly with an idempotency keyIt may have succeeded before failing to respond
HTTP 400, 404, 422NoDeterministic; the same request will fail identically
HTTP 401, 403No, refresh credentials insteadRetrying the same token is pointless
Read timeout on a writeDangerous without a keyThe classic duplicate-charge path

Why exponential backoff alone is not enough

If a dependency fails for every caller at once, every caller computes the same backoff schedule and they all retry at the same instant. The service recovers, is immediately flattened by a synchronised wave, fails again, and the cycle repeats. Backoff spread the load in time but kept it perfectly aligned.

Jitter is the fix, and the usual recommendation is full jitter: sleep a random duration between zero and the computed backoff, rather than the backoff exactly. It costs nothing, desynchronises the herd, and in published analyses reduces both contention and total completion time compared with plain exponential backoff.

The single most useful sentence in a design interview here: "I'd add jitter, because without it every client retries on the same schedule and the recovery wave is as bad as the original spike."

Retry budgets and amplification

Consider a chain of four services, each retrying three times. A single request at the edge can become 81 requests at the leaf. During an outage, retries do not help - they multiply load against something already failing. Two controls prevent this:

Parameters that are defensible

The surrounding reliability patterns are in microservices interview questions, and the delivery-guarantee half in exactly-once delivery in practice.

Where CoPilot Interview fits

Disclosure: we build an interview assistant, so treat this as a disclosed pitch. CoPilot Interview is a native Windows and macOS app that puts suggested answers on your own screen in about two seconds, across coding, system design and behavioral rounds, with a permanent free tier that needs no credit card.

Frequently asked questions

What is jitter in retry logic and why does it matter?

Jitter randomises the wait before a retry instead of using the exact computed backoff. Without it, every client that failed at the same moment retries at the same moment, so a recovering service is immediately flattened by a synchronised wave. Full jitter - a random wait between zero and the backoff - is the common recommendation.

Which HTTP errors should you retry?

Retry connection timeouts and resets, 429 and 503 while respecting Retry-After, and 500s on writes only when you have an idempotency key. Do not retry 400, 404 or 422, which are deterministic, or 401 and 403, where refreshing credentials is the correct action.

What is a retry budget?

A cap that permits retries only while they remain a small fraction of total traffic, typically a few percent, and fails fast beyond that. It prevents retry amplification, where several layers each retrying three times turn one edge request into dozens at the leaf during an outage.

How many times should you retry a request?

Around three attempts for interactive requests, more only for background work. More important than the count is bounding total elapsed time, so a user-facing request fails within the user's patience, and propagating deadlines so a downstream service does not keep retrying for a caller that has already given up.

Walk into the round with a second pair of eyes

CoPilot Interview is a native Windows and macOS app that puts suggested answers on your own screen in about two seconds, across coding, system design and behavioral rounds. The free tier is permanent: 15 minutes a day, no credit card.

Try it free