During an overload, a service starts shedding load. Soon the load balancer marks several instances unhealthy and pulls them out, and the rest fall over. What happened, and how do you prevent it?
Sketch your own answer first, then compare it with the one below.
A strong answer
The health check is an ordinary request, and it was shed or delayed along with the rest. The load balancer read slow or rejected checks as dead instances and removed them. The same traffic now landed on fewer machines, so each was more overloaded, their checks failed too, and the pool shrank in a spiral until little was left.
The mistake is letting a health check measure load. It should answer a narrow question, whether the process is alive and able to serve, and not whether it is busy. Keep it cheap and answered from memory, with no database call. Give it the highest priority, or serve it on a separate port or thread pool, so it is never queued behind real work.
Also put limits on how much the balancer may remove. Many balancers have a panic threshold: if more than some share of the pool is unhealthy, they ignore health status and send to everyone. That turns a total outage into a degraded service.
A slow instance that is truly overloaded should shed load and stay in the pool. It is better to serve 60 percent of requests from ten machines than 100 percent from four before they collapse.
Sources
- Betsy Beyer, Chris Jones, Jennifer Petoff, Niall Richard Murphy (2016). Site Reliability Engineering, chapter 22, Addressing Cascading Failures.