What is Retry with Backoff?
Retry with backoff, told as a story about guests who rest a moment before lining up again after being turned away.
Rejected guests line right back up immediately, and the booth gets even busier.Retrying instantly, with no rest, gives the booth no breathing room.
If everyone retries at once, the crowding only gets worse.Everyone comes back at the same instant, in one big wave.
Rest a moment, then line up again — each person waits a slightly different amount.So everyone doesn't rush back at once.
Each failure doubles the wait, and each person's wait is nudged slightly differently.1 second, 2, 4 — it doubles each time.
Retry forever and you just wait forever.You need a max count and the sense to give up.
Retry with backoff = instead of retrying instantly, resting a bit after rejection, waiting longer each time it fails, with each wait nudged slightly differently per guest — and giving up after too many tries.
Resending a failed request, but doubling the wait each time, is called exponential backoff. Adding a random variation to that wait is jitter — without it, everyone retries at the exact same moment, a thundering herd. Once the max retry count is exceeded, give up and hand off to something like a circuit breaker instead.
When grown-ups say it
- Retry
- Lining up again after a failure. Doing it instantly only makes the crowding worse.
- Exponential backoff
- Doubling the rest time with each failure. 1 second, 2, 4 — it keeps doubling.
- Jitter
- Adding a small random difference to each person's wait. Keeps everyone from rushing back at the exact same moment.
- Max retry count
- The number of tries allowed before giving up. Without it, you just wait forever.
- Timeout
- The limit on how long one attempt is allowed to wait. Only after the timeout passes does it count as a failure and start a retry.
- Circuit breaker
- The red button that stops even retrying somewhere entirely broken. Exceed the max retries, and this takes over. → the red button you press when something breaks
- Idempotency
- Sending the same request more than once still gives the same result as sending it once. Retrying safely depends on this property being true.
- Backpressure
- The entrance slowing itself down when the inside is full. Too many retries piling up is exactly when this becomes necessary too. → slowing the entrance for a moment