policybook / retry
retry
Policies for deciding how long to wait before trying again. The delay curve is the part everyone already knows. The part that decides outcomes is where the randomness goes.
Choosing one
| If you need | Use | Because |
|---|---|---|
A sensible default | Same curve as exponential, spread across a fleet: 2.6% peak against 15.1%. | |
The backoff to actually back off | Guarantees a floor of half the ceiling. Full jitter can return zero every time. | |
To disperse a fleet as thoroughly as possible | Whole schedules diverge, not just individual attempts: 1.1% peak, the lowest here. | |
A delay sequence reproducible without randomness |
| |
To honour a server that told you when to return | 99.6% success against 19.9%, and the worst herd of any policy here. | |
The naive baseline, to measure against |
|
Benchmarks
Success rate on each trace, measured by this repository's benchmarks.
| Policy | outage-30s |
|---|---|
| Retry-After aware | 0.9960 |
| Exponential | 0.4000 |
| Equal jitter | 0.3020 |
| Decorrelated jitter | 0.2580 |
| Exponential with full jitter | 0.1990 |
| Constant | 0.0180 |
Every policy
Retry-After aware
Honour the server's Retry-After when it sends one, clamped, and fall back to full jitter when it does not. Far the highest success rate, and the worst herd.
Exponential
Double the wait after every failure, up to a cap. Load on a struggling service falls geometrically, but every client still comes back at the same instant.
Equal jitter
Half the exponential delay fixed, half of it random. Guarantees a floor that grows with the attempt, where full jitter can return zero every time.
Decorrelated jitter
A random walk that grows from the last delay rather than the attempt number. The only stateful policy here, and the one that disperses a fleet most thoroughly.
Exponential with full jitter recommended
Exponential backoff, then a uniform random delay between zero and that. Cuts the peak simultaneous retries roughly sixfold: the default worth shipping.
Constant
Wait the same amount every time. Fastest to notice a short outage, and the purest form of the thundering herd: every client comes back at the same instant, forever.