Setting up two apache webservers and load balancer on EC2

amazon ec2apache-2.2load balancing

I have an app already deployed on Ubuntu EC2 machine. I am using Apache2 web server, phusion passenger and MySQL. Now I want to add one more server, but I don't know how to set up servers on EC2. Any help will be appreciated.Thank you.

Best Answer

There's several 'right' ways to do this. The lowest barrier of entry would be to create an ami image of the first ec2 machine. Use that custom ami to create a second server with a different host name. From there, you can:

a) (easiest, cheapest) add the second web server to your DNS, serving your pages 'round robin.' Basically, when a new client asks for your website name, your DNS provider alternates between the two server IPs, effectively sending half of your traffic to one server, and the other half to the other.

http://www.rrdns.com/round-robin-dns-setup-a-howto.html

b) (a little more expense, a little more difficult to set up) use Amazons Elastic Load Balancer. Amazon documents this solution well:

http://aws.amazon.com/elasticloadbalancing/

c) (a good bit more expense, a lot more difficult depending on skillset, most flexibility and control) stand up a load balancing instance (or ideally two, using HA proxy.) This method is also well documented, but requires a fairly high degree of experience.

http://backreference.org/2012/04/25/load-balancing-and-ha-for-multiple-applications-with-apache-haproxy-and-keepalived/