A while back at work I had to create a configuration for an internal squid http accelerator, and thought “hey, wouldn’t it be neat if I could load balance thefraggle.com with this method”.
Now, usually Squid is used to act as a caching proxy server, which means that client http requests are sent to the proxy server, the proxy server then goes out onto the web and attempts to grab the request, and returns the entry back to the client; in the process caching the pages (depending on the way the cache has been set up).
Another neat feature that squid supports, is that it can be configured to act as a caching http accellerator. This means that you can sit a squid instance masqerading itself as your website, infront of your multiple webservers/application servers, and it will serve traffic on their behalf, performing basic round robin load balancing, and caching results based on your cache configuration.
The way I decided to setup this load balancing, was to use my existing main server (beastie.thefraggle.com) as the squid and primary webserver, and to use my new VPS with bitfolk (etch.thefraggle.com), as the secondary webserver. From reading the SquidFAQ I managed to come up with the following configuration:
http_port 22.214.171.124:80 defaultsite=www.thefraggle.com vhost
cache_peer 127.0.0.1 parent 80 0 no-query originserver round-robin
cache_peer 126.96.36.199 parent 80 0 no-query originserver round-robin
The rest of the configuration was as standard, but if you want to see the entire thing I’ve included the file to this post:
As you can see it’s not the most pretty configuration ever, but it was a starting point 🙂
HTTP ACCEL is a pretty neat feature huh? However, I’m not sure of how useful it may be in the future, as from what I can see there is now an extension to mod_proxy in apache2, called mod_proxy_balancer; This may be able to manage this same simple kind of http load balancing. Future posts may well include how to use this, and how to do simple mysql balancing/replication 🙂