🏗️Retry with Exponential Backoff
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
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
}Common mistake
Key takeaways
- 1Try again. Many failures are brief.
- 2Wait longer each time. Often double.
- 3Add jitter. And a limit.