Several independent load balancers all route to the least-loaded backend using load numbers that are a little out of date. What can go wrong, and how would you reduce it?
Sketch your own answer first, then compare it with the one below.
A strong answer
The failure is herding. If a backend looks idle in the stale data, every balancer sends its next requests there at once. By the time fresh numbers arrive, that backend is the most loaded. Then they all avoid it and a different backend is flooded. Load oscillates instead of settling.
Ways to reduce it:
- Randomize. Pick two or a few candidates at random and choose the best of those, so balancers do not all converge on the same server.
- Count your own recent sends as part of the load estimate instead of relying only on reported numbers.
- Report load more often, or piggyback it on responses so it is fresh on the next decision.
- Use a smoother signal, such as an exponentially weighted latency, rather than an instantaneous count.
A single balancer with exact counts does not have this problem. The risk grows with the number of balancers and the age of the data.
Sources
- Michael Mitzenmacher (2001). The Power of Two Choices in Randomized Load Balancing.
- Michael Mitzenmacher (2000). How Useful Is Old Information?.