Why exponential backoff with jitter matters more for LLM APIs than for typical REST calls
LLM providers rate-limit per organization on tokens and requests per minute; lockstep retries after a 429 synchronize bursts and self-inflict outages. Jitter desynchronizes; caps bound damage.
Imagine a hundred people all trying to walk through a revolving door at exactly the same second. The door jams, everyone backs up, then everyone steps forward together again. The door jams again. The fix is for everyone to wait a slightly different random number of seconds before trying again, so they arrive spread out instead of in a pack. That random pause is jitter. The longer wait each time after a failure is backoff. And the maximum number of tries is the cap. Together they turn a stuck door into a slow but unblocked door. LLM APIs work just like that revolving door, with rate limits as the chokepoint.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Retry with exponential backoff is one of the oldest patterns in distributed systems. The reason it deserves fresh discussion in the LLM context is that hosted LLM APIs combine two characteristics that make bad retry logic especially destructive: organizational rate limits (the budget is shared across every instance and region you run) and per-call cost (every retry is real money on a vendor bill, not just CPU time).
This walkthrough covers why the pattern matters more here than in typical REST work, the three pieces (backoff, jitter, caps) and what each one fixes, the production failure modes teams hit (nested retries, async fan-out, ignored Retry-After headers), and the operational pattern of centralizing retry logic at the gateway layer rather than re-implementing it per-application.
The thing to internalize: a lockstep retry storm against your own provider is indistinguishable from a DoS attack the provider will defend against. The backoff and jitter are not nice to haves; they are the difference between transient blip and self-inflicted outage.
Why LLM APIs amplify bad retry logic
Organizational rate limits
Hosted LLM providers enforce rate limits at the organization level, typically on two dimensions:
- Tokens per minute (TPM): total input plus output tokens across all calls from your organization in a 60-second sliding window.
- Requests per minute (RPM): total number of API calls in the same window.
When you breach either, the API returns 429 (Too Many Requests) with a Retry-After header. The rate-limit pool is shared across every instance, every region, every cron job, every async batch in your organization. There is no per-process or per-region escape hatch.
The lockstep amplification
When rate limits trigger, many concurrent requests get 429s in the same moment. If each one retries on a fixed delay (say, 5 seconds), all of those clients retry at exactly second 5, all hit the same rate-limit window, all get 429 again. Now they all wait another 5 seconds and retry together. The retry loop becomes a self-inflicted synchronized DDoS against your own provider.
The provider has no way to distinguish your synchronized-retry pattern from a malicious attack. They may aggressively rate-limit your organization, trigger a manual review, or in extreme cases temporarily suspend your account. None of these are good outcomes.
Per-call cost
Every retry is a real API call against your billing meter. A retry storm that does eventually succeed has burned multiples of the normal token budget. Cost spikes from runaway retries are a real incident class.
Why standard REST work does not feel this as acutely
Most backend REST APIs have per-instance or per-IP rate limits, not organization-wide. A retry storm from one instance does not starve another instance. And per-call cost is usually negligible compared to engineering time. LLM APIs flip both: shared organizational budget and meaningful per-call cost.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Anthropic Python SDK and OpenAI Python SDK both ship with exponential backoff plus jitter as the default retry behavior; max attempts and max delay are configurable.
- LiteLLM, Portkey, Vercel AI Gateway, and Cloudflare AI Gateway implement the full retry stack at the gateway so individual applications do not have to re-implement it.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy is full jitter (random(0, cap)) generally preferred over equal jitter (cap/2 + random(0, cap/2))?
Full jitter produces a uniform distribution over [0, cap], which maximally desynchronizes concurrent clients. Equal jitter has the same average delay but a narrower distribution, which leaves clients more synchronized. The original AWS architecture-blog post on jitter algorithms shows full jitter wins on average throughput in synchronized-retry scenarios.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Retrying with a fixed delay and no jitter. Every client that 429ed at second 0 retries at second 5 together, hits the same rate-limit window, 429s again. The retry loop becomes a synchronized DDoS of the provider by your own fleet.
60 second bullets to scan on the way to the call.
Exponential backoff formula and typical delay sequence
Full jitter vs equal jitter and why full jitter desynchronizes better
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.