In this lesson · topic 1 of 7
Topic 1
When a retry makes it worse
4 min read
A retry is a good idea, usually
Networks drop packets. A server restarts. A request lands on a process that is shutting down. For these, the right response is to try again, and the second attempt works. Retrying turns a lot of small failures into nothing. Every client library offers it, and most turn it on.
The idea assumes that the failure was random and that trying again does not make the next failure more likely. That assumption holds for a blip. It fails for overload.
Retries are extra load, sent at the worst time
Say a dependency is slow because it has too much work. Some requests time out. Each timed-out client tries again. The dependency now has the original work and the retries, all of it while it is already behind. It gets slower, more requests time out, and more retries arrive.
Two things make this worse than it sounds.
The failed work is not cancelled. A client that times out walks away, but the request is still in the dependency’s queue. The dependency will spend a full service time on it later, for nobody. A retry then adds a second copy of the same request.
It can outlast its cause. If retries keep the queue so long that every answer is late, the dependency never catches up, even after the original problem is gone. The overload is now held in place by its own symptoms. Researchers call this a metastable failure: the trigger is gone and the failure stays.
Here is the situation to predict. A dependency loses most of its capacity for a short while, then fully recovers. The clients retry every failed request straight away, up to four attempts each.
Predict first
An incident that outlives itself
In the lab the incident lasts 40 ticks. With no retries, the requests that began after it ended succeeded 99%measured of the time. With immediate retries it was 0%measured. The dependency’s queue was full at 150measured requests, and it had spent its capacity on 2268measured requests whose clients had already gone, against 163measured without retries.
The next topic goes through the tools that stop this: timeouts that mean something, backoff, jitter, budgets and circuit breakers.