Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Possible Duplicate:
Apache Failover and Load 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.

share|improve this question

migrated from stackoverflow.com Dec 25 '09 at 17:59

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Adam Gibbins, pQd, womble, Dennis Williamson, splattne Dec 26 '09 at 17:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4 Answers 4

If your company is serious about this, they could consider a device like the Cisco CSS Content Services Switch 11501 series. We use this device with several web/app servers to both balance load and provide redundancy.

share|improve this answer
2  
That's a ridiculously expensive solution when commodity servers running free/open-source software would do. –  Tom O'Connor Dec 25 '09 at 19:51
1  
...but it is a solution! –  David Newcomb Aug 3 '12 at 15:45

If you don't have money to buy load balancers, you can make an Apache server load balancer by configuring mod_proxy_balancer. To make your architecture completely redundant, you will need to run two instances of your load balancer and you can point your domain to both IPs. The other option is to use VRRP or CARP described in Theo's book which will require help from networking operation team.

share|improve this answer

+1 for Scalable Internet Architectures.

What I'd do, is sit down and look at what's currently running on the server in question.

I'm going to assume for now that you're running linux, although you didn't explicitly say this. What you want to look at is Varnish. It's a high performance reverse-proxy and load-balancer. You can set it up following the online examples here and it should be straightforward to get working.

If you have 2 varnish nodes out of 3 servers, point 1/3 of the traffic to each of the servers, arranged as a round-robin assignment. These 2 servers need unique public IP addresses, and you can set multiple A records in DNS to do RoundRobin DNS (RRDNS).

If your service is critically important to the business, and your last outage cost serious money, you might want to argue for a more resillient and redundant network. Assuming you currently only have one server, on one IP provided by one supplier, if your previous outage was network related, you might find that increasing the network resilience would improve your uptime.

Look hard at your monitoring also, make sure you're monitoring things on the server(s) that could bring the server(s) down, SMART data on the hard disks, free swap space, free memory, free / disk space. Get Nagios and Munin set up. Nagios to alert when critical monitoring conditions are met, and Munin to graph these data.

You'll probably have to make some application level changes too. Assuming your application(s) are session based, you'll need some way to handle the user's requests not always going to the same server. You could make them client side, or server-side and sticky. You'll probably find that memcached will help you greatly here.
As for application level changes, you might want to ask on StackOverflow, as they're more code-y and less server-y.

share|improve this answer

Run -- do not walk -- to Amazon.com and buy

http://www.amazon.com/Scalable-Internet-Architectures-Theo-Schlossnagle/dp/067232699X

Do not waste any time on this until you have read -- and understood -- this book.

You do not want (or need) a single-point-of-failure load-balancer.

What you want is a simple Wackamole load-sharing solution.

And you want a single database used by all of your front-end PHP servers.

share|improve this answer