A backend crashes in the middle of a busy afternoon. How does the load balancer find out, and how fast can it react?
Sketch your own answer first, then compare it with the one below.
A strong answer
There are two mechanisms, and sound setups use both.
Active health checks are probes. The balancer sends each backend a cheap request on a schedule, for example an HTTP GET to a health path every 5 seconds. After a set number of failures in a row the backend is taken out of rotation, and after a set number of successes it is let back in. Probing every 5 seconds and requiring 3 failures means up to about 15 seconds during which real requests still reach a dead machine.
Passive checks watch real traffic. If a backend returns a run of errors or resets connections, the balancer stops using it after those few requests, without waiting for the next probe. That is fast, but it needs traffic to learn from, and it spends a few real requests to find out.
Two details matter in practice. The health path should test what the backend needs to serve traffic, such as its connection to its database, not only that the process is alive. And there should be a limit on how much of the pool can be removed at once, so a failure in a shared dependency cannot empty the pool and turn a partial outage into a total one.
Sources
- Envoy project (2024). Health checking, Envoy architecture overview.
- Envoy project (2024). Outlier detection, Envoy architecture overview.