I am using Ubuntu 15 and I need to implement simple/effective Load Balancer / Fail Over System as per the below requirements:

a. It should balance the load between two different public IPs (two different servers on different VPS hosting companies). I need to balance my web application (PHP, MySQL) and also my email server (Postfix, Dovecot, Spamassasin, clamAV, amavis)

b. I don't want to use more than two servers. The project (web application+ email server) are deployed on two servers and I have only two IP addresses (IPv4).

c. I don't want single point of failure, i.e., the load balancer/failover must work on both servers, so in case one machine is down, the second will take over.

I have seen many tutorials on how to make the balancer on servers on same subnet, but I need to make it between two servers on different datacenters.

Would you please advise if this can be done? I would greatly appreciate if you provide me with a simple tutorial or hints to do it. I am still beginner to this technology.


  • Do you want to do this from a single site to the two servers?
    – Ron Maupin
    Apr 24 '16 at 4:46
  • Anything that is possible. Its like I have application server on two different data centers with two different public IP addresses. One of the method is to use DNS round ROBIN but it isnt very convenient for my application as it is a fully state-full application. I checked on LVS-IP tunneling seems legit but still cant get around fixing it. Apr 24 '16 at 4:53
  • I need to understand if you are going to access these servers from a single site, or if they will be accessed from multiple sites.
    – Ron Maupin
    Apr 24 '16 at 4:55
  • from a single site if i am accessing. Apr 24 '16 at 4:58
  • There are products which do this. You could place a load balancer on your network, and use a single address for the two servers. You could then load balance in your choice of methods. Most of your question is really off-topic here, since protocols above OSI layer-4 are explicitly off-topic, as are product and/or resource recommendations and server configurations. You will probably get more help on Server Fault, but recommendations are off-topic there, too.
    – Ron Maupin
    Apr 24 '16 at 5:06

What you need is a DNS server that does health checks. There are both on-prem and hosted options available from multiple vendors. These can serve up DNS responses based on (among other things):

Getting an HTTP 200 (OK) code from the servers
Round robin
Client count balancing
Client physical location
Server response time
Word matches on pages (more accurate than just the HTTP 200)

Since this is basically PBR's cousin, I feel it is on-topic for this site.

Not the answer you're looking for? Browse other questions tagged or ask your own question.