Lab · Reliability

Retries, backoff & jitter

Retrying a failed request is the simplest fix for transient errors — and a classic way to take down a struggling service. Compare retry policies during an outage and a traffic spike, and watch how much extra load each one creates.

Try it

Lab time 3.0 s
Clients, Exponential backoffClientsExponential backoff18 new requests/sService, handles up to 30 requests/sServicehandles up to 30 requests/sreceiving 21/s
  • Clients — Exponential backoff — healthy — 18 new requests/s
  • Service — handles up to 30 requests/s — healthy — receiving 21/s
  • Request
  • Retry
  • Response
  • Error / rejected
Load on the service
21/s of 30
within capacity
Attempts per request
1.03×
1.00× = no extra load
Peak load
32/s
Requests that succeeded
100%
Gave up
0
user saw an error
Duplicate charges
0
no replies are being lost
Recovery after outage
—
until 95% succeed again

Numbers add up:70 requests = 64 succeeded + 0 gave up + 6 in progress; 72 attempts = 70 first tries + 2 retriesThe lab checks this sum as it runs, so a counting mistake would show here.

Controls

Retry policy

Wait 250 ms, 500 ms, 1 s… before each retry.

Client-side throttling

Each client drops a request itself when the service has rejected most of its recent requests.

Traffic
18/s

The service handles up to 30/s and rejects the rest.

Lost replies and idempotency keys
0%

Every attempt of a request carries the same key, so the service does the work once.

A lost reply means the service did the work, such as charging a card, but the client never heard back.

Trouble
Attempts per second reaching the service (shaded: outage)
First attemptsRetriesCapacity
012.52537.5501s2s3s
Show data table
TimeFirst attemptsRetries
1s300
1s320
2s300
2s162
3s200
3s122

Recent retried requests

succeededwait 250 ms0 s1.5 s after the first attempt

What just happened

Nothing yet. Start traffic or run an experiment.

Compare two retry policies through the same outage

Both sides get the same new requests at the same moments, and the service fails on both from 8 s to 12 s. Only the retry policy differs, so any gap comes from the policy. Both sides start with 20 seconds already run.

Side 1 retry policy

Wait 250 ms, 500 ms, 1 s… before each retry.

Side 2 retry policy

Wait a random time between 0 and the backoff, so clients spread out.

18/s
Lab time 20.0 s
Side 1 Exponential backoff
Clients, Exponential backoffClientsExponential backoff18 new requests/sService, handles up to 30 requests/sServicehandles up to 30 requests/sreceiving 22/s
  • Clients — Exponential backoff — healthy — 18 new requests/s
  • Service — handles up to 30 requests/s — healthy — receiving 22/s
Attempts per second (shaded: outage)
First attemptsRetriesCapacity
02550751001s10s20s
Show data table
TimeFirst attemptsRetries
1s300
1s320
2s300
2s162
3s200
3s122
4s140
4s220
5s202
5s140
6s184
6s240
7s80
7s180
8s140
8s180
9s124
9s2014
10s1430
10s2034
11s2040
11s1256
12s3846
12s860
13s2054
13s1050
14s1212
14s1828
15s204
15s222
16s160
16s200
17s220
17s146
18s140
18s240
19s200
19s220
20s180
20s260
Side 2 Backoff + jitter
Clients, Backoff + jitterClientsBackoff + jitter18 new requests/sService, handles up to 30 requests/sServicehandles up to 30 requests/sreceiving 22/s
  • Clients — Backoff + jitter — healthy — 18 new requests/s
  • Service — handles up to 30 requests/s — healthy — receiving 22/s
Attempts per second (shaded: outage)
First attemptsRetriesCapacity
02550751001s10s20s
Show data table
TimeFirst attemptsRetries
1s300
1s320
2s300
2s162
3s200
3s122
4s140
4s220
5s202
5s140
6s182
6s240
7s80
7s180
8s140
8s180
9s1210
9s2026
10s1436
10s2036
11s2054
11s1250
12s3858
12s870
13s2040
13s1032
14s1218
14s182
15s200
15s220
16s160
16s200
17s224
17s148
18s140
18s240
19s200
19s220
20s180
20s260
  • Request
  • Retry
  • Response
  • Error / rejected
Compare two retry policies through the same outage: the numbers for each side and the gap between them
MeasureSide 1 · Exponential backoffSide 2 · Backoff + jitterGap
New requests from users376376Same requests
Attempts sent (first tries + retries)601 (1.60×)602 (1.60×)Exponential backoff lower by 1
Busiest moment, attempts per second8496Exponential backoff lower by 12
Rejected as overloaded (503)4937Backoff + jitter lower by 12
Requests that succeeded332323Exponential backoff higher by 9
p95 latency (slowest 5%)3.0 s2.2 sBackoff + jitter lower by 754 ms
Recovery after the outage (95% succeed again)3.0 s2.0 sBackoff + jitter lower by 1.0 s

Changing a setting starts both sides again, so the numbers always describe one setup from its start. Jitter picks each wait at random, but from its own random numbers, so both sides still get the same new requests. A gap in one row can point the other way in another: read the whole table.

Incident drill: The service goes down while clients retry at once

Traffic is close to the limit: 26 new requests a second, and the service handles 30. Something will go wrong soon. Watch "Requests that succeeded" and "Load on the service". The drill takes about 2 minutes at the default speed; the speed control above the diagram makes it faster.

What this model simplifies
  • A lost reply is drawn as an error coming back. In real systems nothing comes back, and the client waits until its timeout.
  • Failures are instant 503s. Real failures are often timeouts, which also tie up client threads while they wait — making retries even more expensive.
  • The service rejects anything above 30 requests/s in each quarter-second. Real services degrade gradually before they fall over.
  • Only one layer retries. In real call chains each layer may retry, and the amplification multiplies across layers.
  • Rejecting a request costs the service nothing here. On a real server each reject still uses CPU, which is why client-side throttling helps it recover.