http load balancing with squid

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 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 ( as the squid and primary webserver, and to use my new VPS with bitfolk (, as the secondary webserver. From reading the SquidFAQ I managed to come up with the following configuration:

http_port vhost
cache_peer parent 80 0 no-query originserver round-robin
cache_peer 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:

Squid Configuration

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 :)

3 thoughts on “http load balancing with squid”

  1. Pingback:

Leave a Reply

Your email address will not be published. Required fields are marked *