A client makes up to 4 attempts per request. If each attempt fails independently 20 percent of the time, how many attempts does it make per request on average? What if the dependency is fully down?
Sketch your own answer first, then compare it with the one below.
A strong answer
Count the chance of reaching each attempt. The first always happens. The second happens if the first failed, which is 0.2. The third needs two failures, 0.2 squared, which is 0.04. The fourth needs three, 0.008. The average is 1 + 0.2 + 0.04 + 0.008 = 1.248 attempts. A 20 percent failure rate costs only about 25 percent extra load, and the chance a request still fails after four tries is 0.2 to the fourth power, 0.0016, or 0.16 percent. That is a good trade.
If the dependency is fully down, every attempt fails, and every request makes all 4. The load is four times normal. It is multiplied exactly when the dependency can least afford it.
That is the whole case for a budget or a breaker. The retry limit gives a good return when failures are random and rare, and a terrible one when they are correlated. Independent failures are the assumption behind the first calculation, and an overload is the opposite of independent.
Sources
- Betsy Beyer, Chris Jones, Jennifer Petoff, Niall Richard Murphy (2016). Site Reliability Engineering, chapter 22, Addressing Cascading Failures.