A backend running at 80 percent load has a short blip and fails a fifth of its requests. Clients retry every failure up to three times. What happens to the load, and how do you stop it from spiralling?
Sketch your own answer first, then compare it with the one below.
A strong answer
Work out the attempts per request. With failure rate f and up to three retries, each request makes 1 + f + f² + f³ attempts on average. At f = 0.2 that is about 1.25, so the 80 percent load becomes 100 percent. The backend is now at capacity, queues build, more requests fail, and f rises. At f = 0.5 the multiplier is 1.9 and the offered load is 150 percent of capacity. A blip has become an outage that outlasts the original cause.
It gets worse across layers. If a frontend retries 3 times against a service that retries 3 times against a database, one user action can become 4 × 4 × 4 = 64 database attempts.
The defences:
- A retry budget per client, such as retries may not exceed 10 percent of requests, so extra load is bounded.
- Randomized exponential backoff, so retries do not arrive in synchronised waves.
- Retries at one layer only, and a cap on attempts per request.
- Deadlines that travel with the request, so nobody retries work whose answer is no longer wanted.
- Server-side shedding, so a struggling backend rejects cheaply rather than slowly.
Sources
- Mike Ulrich (2016). Addressing Cascading Failures.
- Alejandro Forero Cuervo (2016). Handling Overload.