Search code examples
load-balancingip-addresshaproxydistributed-systemsystem-design

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

  1. 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.


Solution

  • This sort of thing is generally achieved by either putting both load balancers in DNS ("round-robin DNS") so a lookup for app.example.com might resolve to either lb1.example.com or lb2.example.com, or by having an anycast IP address that can route to any individual load balancer (where the one chosen depends on the network topology between a client and the load balancer).