Exponential Backoff Explained: How Retries Learn to Wait

Exponential backoff explained in plain terms means understanding why a sensible retry waits longer each time it fails. The central question is what a client should do when a request fails because the service is overloaded, and the answer is to wait, and then to wait twice as long, so that the retries themselves do not become the overload.

Exponential backoff is a retry strategy in which the delay between attempts grows exponentially, usually by doubling after each failure. A client that fails might wait one second, then two, then four, then eight, up to a maximum, rather than retrying immediately or at a fixed interval.

The idea is simple: a failure often means the service is struggling, and a flood of instant retries makes it struggle more. Waiting gives the service time to recover, and doubling the wait means the load from retries falls away quickly, even when many clients fail at once. This article explains what exponential backoff is, how it works, and where it is used.

Key takeaways

  • Exponential backoff doubles the wait after each failed attempt.
  • It stops retries from overwhelming a service that is already struggling.
  • Random jitter spreads retries out so clients do not retry together.
  • A maximum delay and a retry limit keep waiting bounded.
  • It is the default retry strategy in most cloud SDKs and libraries.

What exponential backoff is

Exponential backoff is a rule for spacing retries, not a rule about whether to retry at all. It applies when a failure is likely to be temporary, such as a service that is briefly overloaded, a network that dropped a packet, or a database that is briefly locked. It does not apply to failures that will never succeed on retry, such as a bad request or a missing permission, which should fail at once.

The strategy was first used in Ethernet, where it is called binary exponential backoff. When two computers on a shared cable transmitted at the same time and collided, each waited a random number of slots, doubling the range after each collision, so that the two would eventually pick different slots and get through. The same mathematics now governs retries across the internet.

The doubling is what makes the strategy work. After ten failures, the wait is about a thousand times the first wait, so a client that keeps failing quickly stops bothering the service at all, while a client that fails once or twice recovers almost immediately. Our guide to distributed systems explains the setting in which many clients fail together, and our guide to REST APIs explains the interfaces where retry behaviour matters most.

How exponential backoff works

A client starts with a base delay, often a fraction of a second or one second. After the first failure, it waits the base delay and tries again. After the second failure, it waits twice the base, then four times, then eight, and so on, with the delay doubling after every failure. The sequence grows fast: with a one-second base, the fifth retry waits sixteen seconds, and the tenth waits over seventeen minutes.

A maximum delay, or cap, stops the waiting from growing forever. Most implementations cap the delay at something like thirty seconds or a minute, so that a client that keeps failing waits the capped amount between attempts rather than waiting hours. A cap keeps the client responsive while still protecting the service from a flood.

A retry limit bounds the number of attempts. A client might try five times and then give up, returning an error to the user or to the calling code, rather than retrying forever. The limit is a design decision: a payment should be retried carefully and few times, while a background sync can afford many attempts over a long period.

Jitter is the random element that makes backoff work at scale. If a thousand clients all fail at the same moment and all wait exactly one second, they will all retry at the same moment and fail together again, in a pattern called a thundering herd. Adding a random amount to each wait spreads the retries out, so the service receives a steady trickle instead of a synchronized wave.

Full jitter and equal jitter are the two common ways to add randomness. Full jitter picks a random delay anywhere between zero and the current backoff value, which spreads retries widely but makes some waits very short. Equal jitter keeps half the backoff value fixed and randomises the other half, which is a compromise between predictability and spread. Both are widely used, and both are far better than no jitter at all.

A dark control room with a glowing green timeline stretching out, retry markers spaced further and further apart along it
A dark control room with a glowing green timeline stretching out, retry markers spaced further and further apart along it, shows how exponential backoff works: wait, then wait twice as long.

Comparing exponential backoff with other retry strategies

Exponential backoff is one of several ways to space retries, and each was built with a different emphasis. A fixed delay is simple but keeps hammering a struggling service, while immediate retry is the fastest when the failure was a fluke, and each approach fits a different kind of failure.

The table below sets out the main contrasts between the leading approaches.

Aspect Exponential backoff Fixed delay Immediate retry
Wait pattern Doubles after each failure Same delay every time No wait at all
Load on a struggling service Falls away quickly Stays constant Maximum, at once
Recovery after a brief fault Fast, first retry is soon Moderate Instant
Thundering herd risk Low, with jitter High, without jitter Very high
Best for Overloaded services Simple, rare failures One-off flukes

The practical result is that exponential backoff is the right default for retries against a shared service, a fixed delay suits simple cases where the service is not overloaded, and immediate retry should be used at most once, for a failure that was clearly a fluke.

Where exponential backoff is used

Cloud SDKs use exponential backoff as their default retry strategy. When a request to a cloud API fails with a throttling error or a brief server fault, the SDK waits and retries with backoff and jitter, so that applications recover automatically from the transient failures that are normal in a large distributed system.

Databases use exponential backoff when a transaction fails. If two transactions conflict and one is aborted, the application retries it after a backoff delay, which spreads the retries out and makes it likely that the second attempt succeeds, rather than colliding with the same transaction again.

Message queues use exponential backoff for failed deliveries. When a consumer fails to process a message, the queue waits before redelivering it, and the wait doubles after each failure, so that a message that always fails does not consume the consumer’s time, while a message that failed once is retried quickly.

Network protocols have used exponential backoff since the earliest days of the internet. TCP doubles its retransmission timeout after each lost packet, and Ethernet’s collision handling doubles its wait after each collision, which is why the strategy is built into the lowest layers of networking as well as the highest.

Mobile applications use exponential backoff to save battery and data. When a phone loses its connection, the app does not retry constantly, which would drain the battery and flood the network, but backs off with doubling waits, so that it checks in rarely while offline and reconnects promptly when the network returns.

Strengths and limits

The greatest strength of exponential backoff is that it protects the service it retries. A thousand clients that fail together produce a trickle of retries, not a flood, so the service has room to recover, and the clients that do get through succeed, rather than all failing together in a synchronized wave.

It is also a strength that backoff is simple to implement and easy to reason about. A base delay, a multiplier, a cap, and a retry limit are all that is needed, and the behaviour is predictable enough to be tuned from logs and metrics.

The limits are real, though. Backoff delays the user, and a client that waits a minute between retries feels slow, even when the service recovered after ten seconds. Backoff also does nothing for failures that will never succeed, and retrying those with backoff only wastes time that should have been spent reporting the error.

Exponential backoff checklist

  • Retry only failures that are likely to be temporary.
  • Start with a short base delay, such as a fraction of a second.
  • Double the delay after each failure, up to a cap.
  • Always add jitter so clients do not retry in lockstep.
  • Set a retry limit and fail clearly when it is reached.
  • Respect Retry-After headers; they override your schedule.
  • Make retries idempotent so a repeated request is safe.
  • Log retries; a rising retry rate is an early warning.
  • Test the retry path, not just the happy path.

Frequently asked questions

What is exponential backoff in simple terms?

It is a retry strategy in which the wait between attempts doubles after each failure, so a client that keeps failing waits longer and longer, giving the service time to recover.

Why add jitter to backoff?

Because without it, many clients that fail at the same time will retry at the same time, and fail together again. Jitter adds randomness to each wait, spreading the retries out into a steady trickle.

What is a thundering herd?

It is a wave of clients that all retry at the same moment, usually after a service recovers, and overwhelm it again. Jitter and backoff are the standard defences against it.

How many retries should I allow?

It depends on the operation. A handful is right for most user-facing requests, while background work can afford more. Always set a limit, and fail clearly when it is reached.

Should I retry a 400 error with backoff?

No. A 400 error means the request itself was wrong, and retrying it will fail the same way every time. Backoff is for temporary failures, such as 429 and 503 errors, timeouts, and brief connection drops.

When should I not use exponential backoff?

When the failure is permanent, when the operation is not safe to repeat, or when the user needs an immediate answer. In those cases, fail fast and report the error instead of waiting.

The bottom line

Exponential backoff explained in one line is this: wait a little, then wait twice as long, and let the service breathe.

It is the retry strategy that keeps a struggling service alive, and the reason a thousand failing clients produce a trickle instead of a flood.

This article is general information about how exponential backoff works, not advice about designing retries for a particular system.

Latest articles

Scroll to Top