Timeouts, retries, backoff and fallbacks: living with parts that break.
In a distributed system, something is always broken: a server, a disk, a network link. Handling failures means designing so that a broken part does not break the whole.
With one machine, failure is rare and loud: it crashes and everything stops. With hundreds of machines, some part is failing at almost every moment. Disks die, processes run out of memory, networks drop packets, deployments go wrong. The goal is no longer "never fail" but "keep working while parts fail".
The hardest part is that failures are often partial and silent. A call to another service might return an error, or take 30 seconds, or never return, or succeed but lose the reply. From the caller's side, these can look the same. So every remote call needs a plan.
| Failure | What it looks like | Typical answer |
|---|---|---|
| Crash | A process or machine stops and sends nothing | Heartbeats, restart, failover to a replica |
| Omission | A message is lost or a request gets no reply | Timeout and retry |
| Timing (slow) | It answers, but far too late | Timeouts, deadlines, load shedding |
| Partial failure | Part of a request worked and part did not | Idempotency, sagas, compensation |
| Network partition | Two groups of machines cannot talk | Quorums, choosing consistency or availability |
| Byzantine | A node lies or sends wrong data | Checksums, signatures, byzantine-tolerant protocols (rare) |
| Strategy | How it waits | Good and bad |
|---|---|---|
| Immediate retry | No wait | Fast for a single lost packet. Dangerous when the service is overloaded. |
| Fixed delay | Same wait each time | Simple. Many clients retry at the same moments together. |
| Exponential backoff | 1 s, 2 s, 4 s, 8 s ... | Gives the service room to recover. Needs a maximum delay and a maximum count. |
| Backoff + jitter | Backoff with a random part added | Spreads clients out so they do not all come back at once. The usual best choice. |
On failure, try again at once, up to the number of retries you pick. Looks helpful, but multiplies the load on a service that is already struggling.
A simplified model with a simulated clock (no random numbers). The service is down from second 6 for the outage length, and it stays down afterwards while it receives more than 150 calls per second. Backoff is modelled as spreading the retries, so about a third of them land in any one second. The breaker opens on the second failing second.
| Term | Meaning in easy words |
|---|---|
| Fault vs failure | A fault is a broken part. A failure is when the system as a whole stops giving the right service |
| Timeout | A limit on how long to wait for a reply |
| Retry | Trying a failed call again |
| Exponential backoff | Waiting twice as long after each failed try |
| Jitter | A random amount added to a wait, so clients do not retry in step |
| Retry storm | Retries that overload a service and keep it down |
| Idempotent | An action that has the same result if it is done once or many times |
| Graceful degradation | Keeping a smaller, simpler service when a part is down |
| Failover | Moving work from a failed machine to a standby |
| Load shedding | Rejecting some requests on purpose so the rest can succeed |
| Chaos engineering | Breaking things on purpose in a controlled way to find weak spots |
| Choice | We gain | We lose |
|---|---|---|
| Short timeout | Fast failure, fewer stuck threads | Slow but healthy calls are cut off |
| Long timeout | Fewer false failures | Threads and users wait, and queues build up |
| More retries | Hide short glitches | Higher load and longer worst-case wait |
| No retries | Simple and no extra load | Every small glitch reaches the user |
| Aggressive circuit breaker | Strong protection | May stay open when the service has already recovered |
| Fallback data | A working page | Possibly stale or incomplete information |