Page is a not externally linkable
nalin - 4:06 am on Jun 14, 2009 (gmt 0)
DNS: APAPCE: SQUID: MONIT: RSYNC: In essence the above will give you 2 (or more) ips with redundant round robin dns. HTTP(s) requests go into squid on any of the hosts. Squid routes to apache on any of the hosts. Apache servers up the request. If apache fails on one of the machines squid catches it fairly quickly and routs all requests amoung the remaining machine(s). Hopefully monit is able to restart it. If squid fails dns redundancy will force the user to try the other ip. Hopefully monit is able to restart it. If dns fails the machine tries the next dns server. Hopefully monit is able to restart it. Note on most of the above the configuration is a pain - I have set up a few different environments in this way but mainly do so now because I have done it before and can modify preexisting configuration files. Had I known up front what goes into setting up this type of configuration the first time I would not have done it...actually I probably still would have because it is cool :)
Assuming two servers here is a slight level of redundancy on the cheap. The underlying assumption is that you have the same software on both machines. Also I am only covering http/https/dns below.
set up www.example.com so that it goes round robin on all the ips which you are using. All hosts should be running a dns (tinydns or bind) and should be set up as nameservers with your hosting company.
listening either needs to be set up on a non default port or on a lan ip.
squid is a proxy that can be set up and run as a reverse proxy in front of your webserver(s). There are some benefits for doing this on a single server (ie caching static files and not passing the request on to something heavier such as apache). With multiple servers there is more benefit as squid can distribute requests and handle hosts going down.
Squid should be listening on [external ip]:80 (you can make squid handle ssl too if you wish - recommended otherwise your redundance is lost for ssl)
Monit will check the local machine for a downed service and restart it.
I use rsync to share some of the config files and /var/www between the hosts.