dkduckkit.dev

Exponential backoff

Rate Limiting

Exponential backoff is a retry strategy where wait times grow multiplicatively after each failed attempt: 1 s, 2 s, 4 s, 8 s, 16 s, up to a configurable maximum. The exponential growth reduces total retry load during sustained outages — at generation 10, a client is waiting 512 seconds between retries instead of 5 seconds. It is always combined with jitter to prevent synchronised retry waves.

Formula

wait_n = min(cap, base × 2^n) + jitter. Common values: base=100ms, cap=30s, n=attempt number starting at 0.

Why it matters in practice

Linear backoff (fixed 5-second retries) keeps the retry rate constant during an outage, meaning the damaged backend receives the same load as during normal operation. Exponential backoff reduces retry pressure automatically as the outage duration grows — the most critical period is the first few seconds when retry volume is highest. Without exponential backoff, retries turn a brief backend spike into a sustained overload.

Common mistakes

  • Not capping the maximum wait — without a cap, backoff grows unboundedly; clients will eventually stop retrying at all due to connection timeouts.
  • Counting every attempt as an opportunity to grow backoff — reset the backoff counter on successful responses; don't carry over backoff from a previous error session.
  • Using exponential backoff without jitter — as explained in the jitter entry, synchronised exponential backoff produces synchronised retry waves.