Skip to content
BENIBIX Learn

Retry with Exponential Backoff

Development🏗️ ArchitectureDistributed Systems

Also known as Exponential Backoff, Backoff, Retry Logic, Jitter

Try a failed call again. Wait longer before each new try.

Think of it like

Think of it like knocking on a door. If no one comes, you wait a bit longer before each new knock.

Example

Emma's app fails to reach the payment service. It tries again after 1 second, then 2, then 4. The third try works, and the customer never notices.

Why it matters

Networks drop calls all the time. Smart retries turn many small failures into nothing at all.

Definition

Retry with backoff means trying a failed call again, and waiting longer each time. A common plan doubles the wait each time: 1 second, then 2, then 4, then 8. Many failures are brief, so a retry often works. Waiting longer each time gives a struggling service room to recover. A little random extra wait, called jitter, stops many clients retrying at the same moment.

Example code

javascript
for (let i = 0; i < 5; i++) {
  try { return await callPayments(); }
  catch { await sleep(1000 * 2 ** i); } // 1s, 2s, 4s, 8s, 16s
}
Each failed try waits twice as long as the one before it.

Common mistake

Retrying at once and forever. Thousands of clients doing that can keep a service down after it tries to come back.

Key takeaways

  1. 1
    Try again. Many failures are brief.
  2. 2
    Wait longer each time. Often double.
  3. 3
    Add jitter. And a limit.

Compare