Simple Load Balancing using Apache mod_proxy_balancer in Just Three Steps

Apache’s mod_proxy_balancer is a very easy to set up load balancer.

You could say that I was born with a hardware-based load balancer, as I have never personally been involved in the purchasing, evaluation, administration, and so forth of production load balancers. This was left up to the ops team, not the engineers. That said I found setting up a rudimentary load balancing development environment with mod_proxy_balancer to be trivial. My use was limited to being able to verify that my client’s web application was designed correctly to scale past a single server instance in as short a time as possible. For that goal, it met my needs.

To set up a trivial load balancing environment, you really only need three machines – one web server (via which we’ll load balance) and two or more backing web application servers. And there are only three steps to do it…

First, double check that mod_proxy_balancer is provided with your Apache web server and is installed. I found that it was in my Fedora-based installation, though I’ve seen reports of other configurations not having this by default. There are a couple of ways to verify the module is installed, but one way is:

# apachectl -t -D DUMP_MODULES 2>&1 | grep proxy_balancer_module

And another is to look for “LoadModule proxy_balancer_module modules/” in your httpd.conf file.

Second, specify the web application servers over which to load balance by opening your httpd.conf file and adding these lines:

ProxyPass /


Naturally, you’re going to want to change the host names, ports, etc. to be applicable for your environment. Note: IP addresses work just fine, too.

Third, restart Apache and verify that your “worker” servers are receiving and responding to the requests. (The Apache ‘error log’ has some nice output too if you’ve entered something wrong on configuration.)

That’s it. You’ve just set up a simple load balancing environment.

In my case, my web application servers are identical and my needs were fairly simple. However, mod_proxy_balancer includes options for weighting based on request counts, request byte sizes, and static factoring. It also has an optional module to support dynamic reconfiguring of the balanced machines as well. All in all, very recommended for development use.