LESSON 03 · Retries and budgets

Keep retries from sustaining an outage

Retries add load at the moment a service has the least to spare, so they need spacing, randomness, and a hard limit.

SYSTEM VIEW

The failure path

Diagram view
Offered load—
Capacity—
Attempts—

Watch a 30-second slowdown turn into a lasting overload as clients retry, then see what caps it.

  1. Clients send 800 requests a second through the Request queue to the API service, which can finish 1,000 a second. With capacity to spare, a retry after a brief failure helps: it soon succeeds.

    What changed

    • 800 requests/s
    • API service at 800 of 1,000/s
  2. A 30-second slowdown cuts the API service to 200 requests a second. Requests wait in the Request queue, and clients give up after 5 s. The timed-out requests are still queued.

    Slowdown
    200/s for 30 s
    Client timeout
    5 s

    What changed

    • Capacity falls to 200/s for 30 s
    • Requests time out after 5 s
    • Timed-out requests stay queued
  3. Clients retry each timed-out request up to 3 times, so one request can make 4 attempts and load can reach 3,200 a second. The retries add work just when the API service can’t finish what it has.

    Per request
    1 + 3 retries
    Worst case
    800 × 4 = 3,200/s

    What changed

    • Up to 3 retries per request
    • Offered load up to 3,200/s
  4. After 30 s the API service is back to 1,000 a second, but the overload continues. It spends its capacity on queued requests whose callers have left, so almost everything still times out, and each timeout brings more retries.

    What changed

    • Capacity back to 1,000/s
    • Work for callers who left
    • Retries sustain the overload
  5. Exponential backoff doubles the wait, 100, 200, 400 ms, but clients failing together retry in waves. Jitter randomizes each wait, between zero and the backoff, so retries spread out. Immediate retries come at once. None sets a bound: load can still reach 3,200 a second.

    What changed

    • Backoff: 100, 200, 400 ms
    • Jitter: a random wait
    • Still up to 3,200/s
    Backoff
  6. In this example the client, API service and database driver each make 3 attempts, so one user action can become 27 database calls. Retry at one layer, and only for failures that can succeed: not a validation error, or a charge with no idempotency key.

    Each layer
    3 attempts
    One action
    3 × 3 × 3 = 27 calls

    What changed

    • Database
    • 3 attempts at each of 3 layers
    • 27 database calls
  7. A retry budget caps retries at 10 percent of normal traffic, 80 a second on top of 800. Load tops out at 880 a second, below 1,000, so the Request queue drains. The cost: retries over the budget fail fast instead of eventually succeeding.

    Budget
    10% of 800 = 80/s
    Worst case
    880/s, under 1,000

    What changed

    • Database, out of view
    • Retry budget: 10%
    • At most 880/s: the queue drains
    • Over-budget retries fail fast

Space plays · ← → step · Home resets

When retries keep a service down

A service handling 100 requests per second loses most of its capacity for 20 seconds, then the capacity comes back. Clients give up after 5 seconds and retry. Predict whether it recovers.

Each client retries up to 3 times, immediately after a timeout. Healthy capacity is 120 requests per second, so the service is comfortably keeping up before the outage.

Change the setup
3
20 s
120/s

83% utilized when healthy.

Backoff between retries
Protections
Once the outage ends and capacity is back, what happens?

Commit to an answer first. Being wrong here is the useful part.

What this model assumes
  • This is a simplified queue stepped once per simulated second, in one queue served first-in, first-out. It answers “does it recover, and roughly how?”, not “what will the latency be?”.
  • Capacity falls to 20% during the outage. The 5-second client timeout is fixed.
  • A timed-out request stays in the queue and still uses capacity unless dropped, and that is what makes the failure self-sustaining.
  • Real systems add thread pools, connection limits, and autoscaling, which change the numbers. The shape of the failure is what carries over.

For a real-world write-up of this failure mode, see Amazon’s Timeouts, retries, and backoff with jitter.

THE IDEA

How it works

A retry helps when a failure is brief and the service has spare capacity. During overload it adds work to a system that cannot finish what it has. For example, a service handles 1,000 requests per second and normally receives 800. A 30-second slowdown makes requests time out, and clients retry each one up to 3 times, so load can reach 3,200 per second. Timed-out requests are still queued, so the server spends its capacity on work whose callers have left. Almost everything times out, which produces more retries. When the slowdown ends, the overload continues, because retries now sustain it.

Exponential backoff doubles the wait between attempts, such as 100, 200, then 400 ms, up to a cap. Jitter randomizes each wait, commonly between zero and the current backoff value, because clients that failed together otherwise retry in waves. A retry budget caps retries as a share of normal traffic. At 10 percent, load tops out at 880 per second, below capacity, so the queue drains. Backoff alone sets no bound: new requests keep arriving, and each can still make every attempt.

Layers multiply too. If the client, API, and database driver each make 3 attempts, one user action can become 27 database calls. Retry at one layer, and only for failures that can succeed: not a validation error, or a charge with no idempotency key. A budget’s cost is that some requests fail fast instead of eventually succeeding. Notification System retries provider calls with backoff and jitter, and Google Drive uses both to avoid reconnection storms.

DECISION POINT

The client SDK makes up to 4 attempts, a load balancer up to 2, and your API up to 4 against the database. A 20-second database blip became a 40-minute outage, with retries near their maximum throughout. You can ship one change today. What is it?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • Retries can make overload outlast its trigger by keeping the queue full.
  • Backoff spreads retries, jitter decorrelates them, and a budget caps their total.
  • Retry at one layer, since attempts multiply across layers.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
ApplyQUESTION 01

Thousands of clients lose a connection at the same moment, and all back off for exactly 1, 2, then 4 seconds. What should you expect, and what helps?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 3 checkpoints answered correctly to complete this lesson.