Load Balancing/FailOver System For 2 Servers on Different Datacenters

August 19, 2014 4.1k views

I am using Ubuntu 12.04 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.


1 Answer

Looking at your requirements, it sounds like a third-party solution will be your best bet. Look into using something like CloudFlare. That will allow you to eliminate the hardware load balancer as a single point of failure. Since these seem not to be stactic sites, you'll also need to set up the servers to replicate the database between them.

by Jason Kurtz
This second installment of "Scaling Web Applications" will list out the steps necessary for scaling a mysql deployment over two VPS.
Have another answer? Share your knowledge.