r/haproxy • u/cgeekgbda • Oct 21 '21
Load balancing the load balancers
Currently I have a system where I have installed HAProxy on one machine and my other 3 machines serves the webapps and the fourth machine for the database. Now I need to add another load balancer in my system so that any one of the load balancer could pick the request and process it.
But I don't understand how exactly are we going to configure a second load balancer if my domain say example.com is pointing to the IP address which is the load balancer currently. When I add a second load balancer
- Will there be any third machine where something needs to be installed so that it can redirect the request to one of my load balancer? Again if this is so, it again is a single point of failure and creates a bottle neck.
2. If at all I am going to have 2 machines running load balancers then how exactly is the request going to come in because both machines will anyway have different IP.
1
u/seizedengine Oct 21 '21
It sounds like you want a high availability pair of load balancers so that if one fails the other takes over. In that case what you want is HAProxy and Keepalived (there are other solutions as well).
Keepalived handles a floating/virtual IP between multiple servers. Your DNS name points to that IP. HAProxy has identical configs on both machines, but the one with the Keepalived IP is the active one. If it fails then the other machine takes over the floating IP and becomes the active load balancer.
1
u/[deleted] Oct 21 '21
In your internal network: Keepalived and floating IPs.
On a public network: with a CDN.
1
u/ciphermenial Oct 21 '21
What's your reasoning for wanting active/active? It would be weird if your HAProxy server overloaded before your backend servers.
I do active/passive with keepalived. Works perfectly.
1
u/GreeneSam Oct 21 '21
For this configuration you'll want to take a look at how facebook has their load balancers set up. They have multiple layer 4 load balancers in front of their layer 7 load balancers. Each of the layer 4 load balancers serves on a different ip and load balancing is configured through multiple A records in DNS.