Skip to the guide

Timeouts, retries, backoff and jitter

IntermediateConcept3 pages

Every call between services needs four decisions: how long to wait, whether to try again, how long to pause first, and how to stop thousands of callers trying again at the same moment. Get them wrong and a two-second hiccup becomes an outage that keeps itself going.

Phoning a clinic when it opens

The clinic's phone line opens at 8:00, and everyone in town wants an appointment. You let it ring for a minute, hang up and call again. Still not through, you wait a little longer before each new try: one minute, then two, then four. But if everyone redials at exactly 8:01, 8:03 and 8:07, the line is jammed at precisely those moments and quiet in between. The people who wait a random part of each gap get through, and at 8:30 you give up and try tomorrow.

  • the clinic's line → a dependency, such as payments or a database
  • everyone in town → every client calling it
  • letting it ring for a minute → a timeout
  • calling again → a retry
  • waiting longer each time → exponential backoff
  • the random part of each gap → jitter
  • giving up at 8:30 → a deadline and a cap on attempts