Skip to content

How to retry well

Retry only transient errors, use exponential backoff with jitter, cap the attempts, honor Retry-After.

Retries that help

  1. Only transient errors

    Network timeouts, 5xx, 429. Never 4xx client errors; the next attempt will fail identically.

  2. Exponential backoff

    Attempt n waits base * 2^n. Without backoff, a retry is a mini-DDoS.

  3. Add jitter

    Random ±20% on the wait. Without jitter, all clients retry simultaneously.

  4. Honor Retry-After

    If the server says wait 30s, wait 30s. Ignoring it is how rate limits become bans.

  5. Cap the budget

    3-5 attempts max, and a total time budget. Infinite retries are infinite outages.