Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Exponential Backoff
HLD

Exponential Backoff

The rhythm of polite retrying — why wait times grow, and the math that keeps retries from stampeding.

The Schedule

 retry delays grow geometrically:

 attempt 1 fails → wait 100ms   → attempt 2
 attempt 2 fails → wait 200ms   → attempt 3
 attempt 3 fails → wait 400ms   → attempt 4
 attempt 4 fails → wait 800ms   → give up (cap reached)

 delay = base × 2^(attempt-1), capped at max:
     min(base * 2^n, max_delay)

 base ~100ms typical; max ~10–60s depending on operation class.

Why Growth Is the Point

 a struggling dependency needs TIME to recover —
 recovery means draining queues, GC settling, autoscaling.

 linear/eager retries hammer it during exactly that window:

 fixed 100ms retries:      10 req/s sustained pressure ✗
 exponential:              pressure DECAYS as failure persists ✓

 it's automatic load-shaping: the sicker the target,
 the slower the requests arrive. recovery becomes possible.

 second purpose: OUTLIER tolerance. transient blips resolve
 in ms; deeper trouble resolves in seconds. the growing
 schedule spans both without human tuning.

Jitter: The Non-Negotiable Companion

 synchronized clients retry on the SAME schedule:

 t=0:    dependency hiccups. 1000 clients fail together.
 t=100:  all 1000 retry TOGETHER → spike → fail together
 t=300:  all 1000 again...
 
 the THUNDERING HERD — your retry logic DDoSing its own target.

 JITTER randomizes each client's delay:
   delay = random(0, min(cap, base × 2^n))
   (full jitter) or ±50% around computed value (equal/partial)

 result: retry load spreads smoothly instead of pulsing.
 AWS-style guidance: full jitter performs best empirically.

Parameters That Matter

ParameterTypicalNotes
base100–500msbelow p99 of normal latency
factor2rarely tuned elsewhere
max delay5–60sbounded patience
max attempts3–6total envelope matters more
deadlineper-operationattempts must FIT inside
 interactive paths: fewer attempts, tighter cap
   (user is waiting!)
 background/queues: more attempts, generous caps,
   plus DLQ at the end of the road.

Interview Framing

“Batch job hammering an API gets throttled, retries make it worse” scored diagnosis: missing backoff+jitter, prescribe exponential-with-full-jitter with concrete numbers, fit-to-deadline arithmetic, note the decay-pressure property as WHY it works. Two words interviewers listen for: “geometric” and “jitter” — say both, explain the herd once, move on.

My Private Notes

Notes are auto-saved locally to this device.