Hot AI News

Exponential backoff with jitter: How apps retry failed AI requests without making outages worse

When an AI service returns errors, apps retry. Exponential backoff with jitter spaces those retries out and randomizes them so a small outage does not become a bigger one.

Exponential backoff with jitter: How apps retry failed AI requests without making outages worse
Photo illustration: Aiholics

Exponential backoff with jitter is a rule for retrying a failed request. The app waits a little before the second try, longer before the third, and so on. It also adds a random amount to each wait. The goal is to give a struggling service room to recover instead of hammering it.

It is the standard answer to a question every team faces when an AI service starts returning errors: what should the code do next?

A crowd at a locked door

Picture 1,000 people waiting outside a shop that has just closed for a minute. If everyone knocks again every second, the staff cannot hear themselves think when the door reopens. If everyone waits twice as long after each failed knock, the noise fades quickly. If each person also picks a slightly different moment to knock, the crowd spreads out instead of arriving as one wave.

Software clients behave like that crowd. When a service returns errors, thousands of apps may retry at once. Those retries are extra load on a system that is already in trouble.

Advertisements

Three ideas stacked together

The technique combines three simple parts:

  • Retry: try the same request again, because many failures are temporary.
  • Exponential backoff: double the wait after each failure, for example 1 second, then 2, then 4, up to a cap.
  • Jitter: replace each wait with a random value, so clients do not all retry at the same instant.

Backoff alone is not enough. If 1,000 clients fail together, they also wait the same 1, 2 and 4 seconds together, and they return together. Jitter breaks that alignment. The AWS Well-Architected guidance puts it this way: jitter avoids alignment of requests into spikes, and backoff diminishes the load escalation caused by adding retries to normal traffic.

A common form, which AWS calls “Full Jitter”, picks a random wait between zero and the current backoff ceiling. A cap on the number of attempts, and on the longest wait, keeps the loop from running forever.

Where it came from

Backoff is older than cloud computing. It has long been used in network protocols, where devices sharing a link must avoid colliding again after a failed transmission. For web services, Marc Brooker of Amazon Web Services (AWS) published a widely cited post in 2015 titled “Exponential Backoff And Jitter” on the AWS Architecture Blog.

Brooker tested the idea in a simulation with 100 contending clients. According to the post, adding jitter cut the number of calls by more than half and finished the work faster than plain exponential backoff. He also compared “Full Jitter” with “Equal Jitter”, which keeps part of the backoff so waits never become very short.

AWS later folded the idea into its Well-Architected Framework and the Amazon Builders’ Library article “Timeouts, retries, and backoff with jitter”. AWS says most of its SDKs support exponential backoff and jitter in their standard or adaptive retry modes, and recommends using those built-in versions instead of writing your own.

Advertisements

How it shows up with Claude and other AI APIs

AI services are a natural fit. Requests are expensive, capacity is limited, and demand arrives in bursts. Anthropic’s API documentation describes a 529 overloaded_error as a temporary overload that can occur when traffic is high across all users, and a 500 api_error as an unexpected internal error. A 429 error signals a rate limit, which the docs say can also appear after a sharp rise in an organization’s usage.

This is the situation in our report on the Claude Fable 5.2 errors on claude.ai, the API and Claude Code. Anthropic’s status page listed elevated errors, said the cause was identified, and gave no workaround or end time. A team calling the model from its own code has to decide what happens to failed requests in the meantime. Retrying with backoff and jitter, and falling back to another model, is general engineering practice, not guidance from Anthropic’s notice.

Secondary guides commonly advise retrying 500 and 529 errors this way, and failing fast on client errors such as 400 or 401, which a retry cannot fix. They also say Anthropic’s SDKs retry some errors automatically, with a configurable limit. That claim came from third-party sources, so check the current SDK documentation before relying on the defaults.

Limits and traps

Backoff is not a cure for every failure. Some errors are permanent. A malformed request, a bad API key or an exhausted spending cap will fail every time, and retrying only wastes time. One third-party guide warns that a spending-cap 429 may carry no retry hint and continue until access is restored.

Other traps are worth knowing:

  • Retry storms across layers. If an app, a library and a gateway each retry three times, one failure becomes up to 27 calls. Retry at one layer where possible.
  • Non-idempotent actions. Retrying a request that sends an email or charges a card can do it twice. Safe retries need requests that can be repeated without side effects, or a unique key that lets the server spot duplicates.
  • Long waits for people. A chat user will not wait 60 seconds. Interactive tools often retry briefly, then show an error.
  • Server hints. When a response says how long to wait, such as a Retry-After header, honoring it beats guessing. One guide says Anthropic sends it on genuine 429 responses, but that point was not confirmed in the official pages, so verify it.

Retries also do not help when the whole service is down for many minutes. That is where a fallback comes in: a second model, a second provider or a queue that holds work until the incident closes.

Advertisements

What to watch

Agentic tools make retry design more important. A coding agent may make dozens of model calls in one task, so a single flaky minute can ripple through a long job. Expect more tools to checkpoint progress, so a failed step resumes instead of restarting the whole task.

Also watch how providers describe incidents. Status pages that give start times, error rates and advice on retrying let customers tune their backoff to the real problem. For now, the safest default is simple: wait longer after each failure, randomize the wait, cap the attempts, and stop retrying errors that cannot succeed.

Sign Up for the Daily AI Pulse

One email a day. All the stories that matter.

Daniel ReedAI Research, Safety & Ethics Analyst

Daniel Reed currently works as an AI Research, Safety & Ethics Analyst at Aiholics, writing about how changes in artificial intelligence are affecting and will affect scholarship,…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may also like