Module 4 · Lesson 2 of 5

Retrying safely

One retry, then plan B

Retry a brief error once after a short, jittered wait, then fall back; do not repeat a step that changes something without checking first.

Scene 1 of 4 · A brief error

The call fails after 0.3 s with "busy, try again": a brief error that a retry often fixes.

Retries over time, in seconds (made-up timings)

One request

  1. Call or retry at 0 s, call
  2. "Busy" error at 0.3 s, busy
  1. A brief error. The call fails after 0.3 s with "busy, try again": a brief error that a retry often fixes.
  2. Wait, then retry once. The app waits about 1 s, retries once, and gets "busy" again.
  3. Then fall back. It stops retrying and moves on to its fallback, instead of keeping the user waiting longer.
  4. Spread the retries. Without jitter, every client retries at the same moment; with jitter, the retries spread out.
  5. Now you try. A call failed. Pick what went wrong, and see whether to retry. For example: Do not retry blindly. The email may already have gone, so a blind retry could send it twice; check first.

Scene 1 of 4: A brief error. The call fails after 0.3 s with "busy, try again": a brief error that a retry often fixes.

Key points

  1. A "busy" error is often gone a second later.
  2. Retry it once or twice, with backoff, then fall back.
  3. Jitter spreads many clients' retries apart.
  4. A step that sends or books something must never be retried blindly.

Go deeper in the Retries, backoff & jitter lab →

Many model errors are brief, such as a provider saying it is busy, so one retry with often works. The Retries lab shows backoff and at work.

But a retry after a may pay for the again, and retrying an action, such as sending an email, may do it twice. Retry only what is safe to repeat.

Cap the retries, and spread them with jitter, so many clients do not hit a struggling provider at the same moment.

Example. A call fails with "busy, try again". The app waits about 1 s and retries once. If that fails too, it moves on to its instead of retrying again.
Try it yourselfRetries, backoff & jitterOpen the lab →

In system design: Retry brief errors once or twice with backoff and jitter, and never blindly retry a step that changes something.

Check yourself

Which call should you not retry blindly after a timeout?