Apache Failover and Load Balancing

apache-2.2failoverload balancing

I am working for a small finance firm as a Web Application Developer. Our company has an interal website coded in PHP and running on Apache. Recently our server went down and the website was down for several days causing severe problems.

I have been asked to setup two more servers for serving the website. So we want three Apache Web/App servers running on three different machines. When a user logs into the website, he must be servered by one of the three servers depending on the load. Also if one or two of the servers go down, the server which is up must handle the website requests.

I just know creating a website in PHP and hosting it on an Apache server. I dont have any knowledge of networking. Please tell me what I need to learn for creating the above mentioned system.

I am not expecting to be spoon fed. Just need a pointer to what I have to learn to achieve my goal. I'm Googling simultaneously but have asked this question here as I am in hurry to implement it.

Best Answer

A common approach is to develop web-applications that are aware of clustering. You'll probably need to remake your site's basics that's related to database, sessions, shared and dynamic data. I'm sure my question will make you interested: Cloud/cluster solutions for scalable web-services. To make a website 'scalable' you'll need to create a scalable design. Alas, there's no button with "Make it faster" written below :)

A simple way is to replicate all data between these servers (you may use GlusterFS for files, and replicate your MySQL/whatever between these servers) and ensure all sessions are available from all of them! It's not the best suggestion, but you won't have to remake your code :)

Load-balancing can be easily implemented with Round-Robin DNS: just add several 'A' records that point to different servers and they'll be picked randomly by clients. For instance, Google has this feature:

$ host -t a google.com
google.com has address 74.125.87.147
google.com has address 74.125.87.103
google.com has address 74.125.87.104
google.com has address 74.125.87.99
google.com has address 74.125.87.105
Related Topic