Distributed systems · L2Backoff, jitter and retry budgets

Backoff, jitter and retry budgets

Retries rescue one request but can sink a whole system. Here is how to retry without making an outage worse.

L2 SeniorDistributed systems17 min read
Fact-checked by AI against cited sources · Human review pendingLast reviewed 8 Nov 2026 · How we check content
Section 1 of 8

What broke

On 12 June 2025, many Google Cloud APIs returned 503 errors around the world. A bad policy record made Service Control, the system that checks API requests, crash again and again. 1

Google's engineers found the cause within 10 minutes. Within 40 minutes, they had rolled out a switch that turned the failing code path off. 1

That should have been the end. But in large regions like us-central1, the restarting Service Control tasks all hit the Spanner table they depend on. Google calls this a "herd effect". 1

The report says Service Control "did not have the appropriate randomized exponential backoff implemented to avoid this." Engineers throttled task creation to protect that database. Full recovery in us-central1 took up to about 2 hours 40 minutes. 1

So the bug caused the outage, but the missing backoff stretched the recovery. One of Google's fixes: "audit and ensure our systems employ randomized exponential backoff." 1

Section 2 of 8

The idea in simple words

You learned in Idempotency and retries that retries need a key, a limit and backoff with jitter. This lesson is about the system as a whole. One retry helps one request. Millions of retries can keep a failing service down.

Brooker calls retries "selfish": "when a client retries, it spends more of the server's time to get a higher chance of success". 4 That is fine when failures are rare. It is dangerous when the server fails because it is overloaded.

The key idea. Spread retries out in time (backoff with jitter), keep them in one layer, and give them a budget. When the budget runs out, fail fast instead of retrying.

Section 3 of 8

How it works

Retries multiply across layers

You saw in the last lesson that retries multiply when several layers retry. Here are the numbers when each layer makes 1 try plus 3 retries. Step through it with Next and Back, or the ← and → keys.

Retries at every layer multiply; one retrying layer with a budget does notA · Every layer tries up to 4 times App Gateway Service DB ×4Service → DB: 4 calls ×4Gateway → Service: 4 × 4 = 16 DB calls ×4One tap: 4 × 4 × 4 = 64 DB calls B · Only the app retriesAppGatewayServiceDB×4×1×1✓ at most 4 DB calls budget: retries ≤ 10% of requestsDB down for everyone?Most retries are skipped. They fail fast.✓ load ≈ 1.1×, not 4× SeniorPath
  1. Each layer makes 1 try plus up to 3 retries: 4 attempts. The database is down. The service tries it 4 times before it gives up.
  2. The gateway also tries the service 4 times. Each of those tries makes 4 database calls. That is 16.
  3. The app tries the gateway 4 times too. One tap now sends up to 64 calls to a database that is already failing. Count attempts, not retries.
  4. The fix: retry in one layer only. The gateway and the service try once and pass the error up. The app retries, so the database gets at most 4 calls.
  5. Add a retry budget. A client retries only while retries stay under 10% of its requests. In a full outage, total load stays near 1.1×, not 4×.
Step 1 of 5

Google's SRE book gives the same example: 3 layers that each make 4 attempts send 64 attempts to the database for one user action. 6 Brooker's example has five layers with 3 tries each: 3^5 = 243 times the database load. 4 This is retry amplification.

The fix is to retry at one point in the stack. That is Amazon's best practice for low-cost operations. 4 Google adds a rule: only the layer just above the one that failed retries. If its retries fail, it returns an "overloaded; don't retry" error, so callers higher up do not retry again. 5 Amazon does not say which layer. Google picks the layer just above the failure. The diagram lets the app retry. Either way, only one layer retries.

Exponential backoff, with a cap

Exponential backoff doubles the wait after each failure. Without a limit, the wait grows without end, so implementations set a maximum wait. 4 The AWS SDKs, for example, cap each backoff at 20 seconds. 7

Backoff alone is not enough. In Brooker's 2015 simulation, clients that failed together backed off together. They still arrived in clusters, so contention "hasn't been reduced much". 2

The three jitter rules

Jitter adds randomness to each wait. Here are the three rules from the simulator code behind the 2015 post, rewritten as small functions. 3 The base and cap are the AWS SDK values for transient errors. 7 n is the retry number, starting at 0.

import random

BASE, CAP = 0.05, 20.0   # seconds

def expo(n):
    return min(CAP, BASE * 2 ** n)

def full_jitter(n):
    return random.uniform(0, expo(n))

def equal_jitter(n):
    v = expo(n)
    return v / 2 + random.uniform(0, v / 2)

def decorrelated_jitter(prev_sleep):   # start with prev_sleep = BASE
    return min(CAP, random.uniform(BASE, prev_sleep * 3))
  • Full jitter picks the whole wait at random, from 0 up to the capped backoff.
  • Equal jitter keeps half the backoff and randomizes the other half. No wait is ever very short.
  • Decorrelated jitter grows from the last random wait, not from the retry number.

In the simulation, with 100 clients competing for the same resource, jitter cut the number of calls by more than half compared with plain backoff. 2 Full jitter did the least work. Decorrelated jitter finished slightly sooner but made more calls. Equal jitter was the weakest of the three. 2

In their updated retry behavior, the AWS SDKs use full jitter: random(0, 1) × min(20,000 ms, base_delay × 2^retry). 7 Jitter helps outside retries too. Amazon considers adding jitter to "all timers, periodic jobs, and other delayed work". 4 Restarting tasks, like Google's, need it as well.

Retry budgets

Backoff spreads retries out. It does not limit their total. When a backend is down for everyone, every request fails, and every request retries. You need a retry budget.

Google uses two limits. Each request gets at most three attempts. Each client also retries only while retries stay below 10% of its requests. 5 Without the client budget, load can grow to just under 3 times. With it, load grows about 1.1 times. 5 The SRE book also gives a per-process example: 60 retries a minute, then fail instead of retrying. 6

A token bucket is a common way to build this. 4 Real libraries do it:

  • AWS SDKs, standard mode: a retry quota of 500 tokens. A retry after a transient error costs 14 tokens. A success with no retry gives 1 back. When the retry quota is empty, the SDK returns the error at once. 7 These numbers are for AWS's updated retry behavior. You opt in with AWS_NEW_RETRIES_2026=true until it becomes the default. 7
  • AWS SDKs, adaptive mode: adds a client-side rate limiter. It can delay even the first request when the service throttles. 7
  • gRPC: for each server, each failed call with a retryable code takes 1 token, and each success adds back tokenRatio. Retries stop while the count is at or below half of maxTokens. 8

Which errors to retry

Retry only errors that may pass. Do not retry permanent errors or malformed requests, because they will never succeed. 6 gRPC goes further: in general, retry only codes that show the server did not handle the request. 8

Listen to the server. A 503 with Retry-After says how long the service expects to be unavailable. The value is seconds, like Retry-After: 120, or a date. 9 gRPC servers can send the grpc-retry-pushback-ms metadata key: a delay in milliseconds, or a negative value for "don't retry". 8

Deadlines

Retries must fit inside the caller's time limit. Pass the time left down the chain. If a server has a 30-second deadline and spends 7 seconds, it gives the next server 23 seconds. 6 Do not start a retry that cannot finish in time.

Section 4 of 8

Trade-offs

OptionProtects the backend?CostUse it when
Retry at once, no backoffNo Retries pile onto a sick service.Nothing to build.Never, for remote calls.
Exponential backoff, no jitterPartly. Clients still retry in clusters.A little code.Rarely. Add jitter.
Backoff with full jitterYes Retries spread out evenly.Some calls wait longer than needed.Your default for remote calls.
Decorrelated jitterYes Similar to full jitter.Slightly more calls in the 2015 simulation.You want slightly faster completion.
Retry budget (token bucket)Yes Total retries stay small.Some requests fail that one retry could save.Many clients call a shared service.
Retries at every layerNo Retries multiply.Hidden until an outage.Never. Pick one layer.

Simple rule: retry in one layer, with capped backoff and full jitter, under a retry budget. 4 5

Section 5 of 8

At work: how a senior uses this

  • Draw the call chain in design reviews. Ask: "Which layer retries? How many attempts in total, top to bottom?"
  • Read your library's defaults. HTTP clients, SDKs, service meshes and queues often retry on their own.
  • Ask what happens when the backend is down for everyone, not just for one request. A budget should cap the total.
  • Tell callers how to behave when you are overloaded: a 503 with Retry-After to say when to come back, or a "don't retry" error so upper layers do not retry.
  • Add jitter to cron jobs, cache TTLs, reconnect loops and restarts, not just to request retries.
  • Watch the retry rate on a dashboard. A rising retry rate is an early warning of overload.
  • Pair retries with circuit breakers, which stop calls to a failing service for a while. See circuit breakers, bulkheads and fallbacks.
Section 6 of 8

With AI

What to ask the agent

"Find every place in this repo that retries a network call: our code, HTTP client settings, SDK configs and service mesh rules. List the layer, max attempts and backoff for each."

"Wrap this client in a retry policy: at most 3 attempts, full jitter with a 50 ms base and a 20 s cap, and a token-bucket retry budget. Only retry 503, 504 and connection errors. Respect Retry-After."

"Write a test where the backend fails every call for 60 seconds. Assert that retries stay under 10% of requests."

What to check yourself

  • The wait is random from 0 to the capped backoff. It is not a fixed wait plus a tiny random part.
  • The cap is applied before the random pick, not after.
  • Only one layer retries. Other layers pass the error up.
  • Client errors like 400 and 403 are not retried. A 429 is retried only after a wait: the Retry-After value if there is one, or your backoff if not.
  • Retries stop when the deadline has passed or the budget is empty.
  • Calls that change data are idempotent before they are retried.
Section 7 of 8

Check yourself

1. The service calls the database, and the database rejects the call as overloaded. Under Google's rule, which layer retries?

Show answer

Only the service, the layer just above the database. Google retries only at the layer just above the one that failed. If that fails, it returns "overloaded; don't retry" so no one higher retries.

2. With full jitter, how long does a client wait before retry number n?

Show answer

A random time between 0 and min(cap, base × 2^n). Full jitter picks the whole wait at random, up to the capped backoff. The third option is equal jitter.

3. A client sends 1,000 requests a second and keeps retries under 10% of its requests. The backend fails every call. About how many retries a second can the client send?

Show answer

About 100 A 10% retry budget caps retries at about 100 a second, so total load stays near 1.1×.

4. Which response is worth retrying, after a wait?

Show answer

503 Service Unavailable with Retry-After of 30 seconds. A 503 may pass, and Retry-After says how long to wait. The other two will fail the same way again.

Your progress is saved only in this browser. Export it to keep it safe.

Was this clear?
Report a mistake (opens GitHub in a new tab)
Section 8 of 8

Go deeper

Show 9 sources and related lessons
  1. Google Cloud Service Health, “Multiple GCP products are experiencing Service issues” (incident of 12 June 2025; report of 13 June 2025) (opens in a new tab)
    The official report. Read the recovery part, where restarting tasks overloaded a Spanner table.
  2. Marc Brooker, “Exponential Backoff And Jitter”, AWS Architecture Blog (4 March 2015) (opens in a new tab)
    The simulation that compares no jitter, full, equal and decorrelated jitter, with charts.
  3. awslabs/aws-arch-backoff-simulator, backoff_simulator.py (GitHub) (opens in a new tab)
    The short Python code behind the 2015 post, with each jitter rule in a few lines.
  4. Marc Brooker, “Timeouts, retries, and backoff with jitter”, Amazon Builders' Library (opens in a new tab)
    How Amazon caps backoff, limits retries with a token bucket and retries at one point in the stack.
  5. Alejandro Forero Cuervo, “Handling Overload”, Site Reliability Engineering (Google, O'Reilly 2016), chapter 21 (opens in a new tab)
    Google's per-request and per-client retry budgets, and the "overloaded; don't retry" error.
  6. Mike Ulrich, “Addressing Cascading Failures”, Site Reliability Engineering (Google, O'Reilly 2016), chapter 22 (opens in a new tab)
    The 64-attempt example, retry rules and deadline propagation.
  7. AWS SDKs and Tools Reference Guide, “Retry behavior” (opens in a new tab)
    Standard and adaptive retry modes, the backoff formula and the retry quota, with worked numbers.
  8. gRPC proposal A6, “gRPC Retry Design” (GitHub) (opens in a new tab)
    How gRPC clients throttle retries with a token count, and how servers push back.
  9. IETF RFC 9110, “HTTP Semantics” (June 2022), section 10.2.3 Retry-After (opens in a new tab)
    The Retry-After header, its two formats and its meaning with 503.

Real incident: Google Cloud, 12 Jun 2025: Google Cloud outage: blank policy fields crashed API checks

Case studies: Amazon: Timeouts, retries and backoff with jitter done right

Related: Idempotency, retries and timeouts · Tail latency and queueing · Rate limiting · Caching and cache stampedes · Error handling and defensive design · Circuit breakers, bulkheads and fallbacks

Term

See full entry

Jump to a section

  1. 1What broke
  2. 2The idea in simple words
  3. 3How it works
  4. 4Trade-offs
  5. 5At work
  6. 6With AI
  7. 7Check yourself
  8. 8Go deeper