How do you stop a load balancer from being a single point of failure?
- Posted
- Tags
- load-balancing, high-availability, networking
A KodeKloud short on load balancers led me to active-passive and active-active setups.
I was enjoying a quiet Friday afternoon, scrolling mindlessly through YouTube Shorts, when a KodeKloud short came up explaining what a load balancer is for: keeping an app highly available by spreading requests across servers. Near the end they mentioned an active-passive setup, and I realized I did not really know what that meant.
The question I had
How does an active-passive setup work, and why do load balancers need one?
What I found
I started from what I did understand: if a single machine is the load balancer, that machine is a single point of failure. So my first thought was to add more load balancers. Then I thought, why not add another load balancer in front to balance the load balancers? That is not right. It just repeats the problem, because the new one at the front is now the single point of failure.
What actually happens is closer to a leader and follower setup. The load balancers agree to watch each other using a protocol like VRRP (or CARP on BSD systems). They share one virtual IP address, and each one also keeps its own IP. Clients only ever talk to the virtual IP.
clients
|
virtual IP 10.0.0.100
/ \
LB-1 (active) LB-2 (passive)
10.0.0.11 10.0.0.12
\ /
app servers
Active-passive. The leader holds the virtual IP, receives the requests and balances them across the servers. The followers wait on standby. The moment something goes wrong with the leader, one follower steps up, takes over the leader position and the virtual IP, and becomes the active load balancer. It starts receiving requests on the same address and balances them the same way.
Active-active. Same goal, with a twist. Instead of keeping a machine idle on standby, the whole fleet works all the time, each machine carrying a share of the traffic. The catch is that each one has to stay at a comfortable load, enough to absorb the extra traffic if another member dies.
Takeaway
A load balancer keeps an app available when one of its servers fails. Active-passive and active-active setups do the same for the load balancer itself, so it never becomes the single point of failure. One keeps a spare waiting. The other keeps everyone busy with room to spare.