How do I load balance between two Linux machines?
- by William Hilsum
Inspired by the Stack Overflow network, I am now obsessed with HAProxy and trying to use it myself.
At the moment, each HAProxy box has got two network cards (well, two configured, I can have a maximum of 4 and wasn't sure if they needed their own one for management between the boxes).
On both machines, the backend one (eth1) is a private IP that goes to a switch connected to the webservers, and the front facing one (eth0) has a public internet IP that is routed straight though.
In addition, I have created an additional virtual ip for eth0 called eth0:0 which has got a third public ip address.
I just about get how to use it for load balancing between multiple web servers that are behind it, but, I am failing to load balance between the two HAProxy boxes - they appear to fight for the virtual IP, but, this does not appear to be a smart solution.
Now, by using the virtual shared IP address, this solution appears to work and does seem to give me maximum uptime, but, is this the correct way to do it, or is there a smarter way?
I have been looking at other Linux packages such as keepalived, but, I have only been using Linux (server) for a week now and am at the limits of my understanding.
Is there anyone who has done this before and can you advise anything for maximum uptime?