Command Palette

Search for a command to run...

PHASE 10Intermediate ~6 min· topic 14 of 16

Topic 10.14

Retries

In one line

The last request failed. When do you retry, how hard, and how do retries stop being the retry-storm?

0/16 · 0%

Think of it like this

Calling a friend who didn't pick up: you don't call back instantly ten times in a row (that's rude and useless); you wait a bit longer between each attempt (backoff) so you're not just spamming a busy line.

Key ideas

  1. 01

    Idempotency is what makes retries safe: retry against a non-idempotent POST without a key = duplicates (Phase 4 payment).

  2. 02

    Backoff: fixed → jittered exponential (base × 2^n + random) — jitter breaks synchronized retry storms.

  3. 03

    Retry policy: 3 attempts with backoff to the live queue, then → DLQ (dead letter) so human/alerting can intervene.

  4. 04

    Never retry forever: cap attempts + time budget; a stuck retry loop is a slow outage.

  5. 05

    Retry storms: 10k failures all retry → burst; jitter + circuit breakers (10.16/11.8) flatten it.

  6. 06

    Interview: 'idempotent handler, exponential backoff with jitter, cap at 3, then dead letter'.

Java / Spring map

  • →

    Spring Retry (@Retryable(backoff = @Backoff(delay=100, multiplier=2, jitter=50))), Resilience4j Retry.

Explain without notes

01

Why does a fleet retrying on the same schedule amplify an outage? What two mechanisms break the loop?

Practice

01

Write the retry + DLQ configuration for an SMS sender that fails 5% of the time.

Trade-offs

  • ↔

    Aggressive retries = resilience vs thundering herd; backoff dial is the compromise. Cap it and DLQ it.

Run it in production

Completion checklist

  • My default policy is: idempotent + jittered exponential backoff + cap + DLQ — every time.

Back to phase