Web server load balancing is a method for ensuring two things: that your cluster of web servers share the load of visitors to your web site evenly, and that servers which go down will fail over to the next available server. What seems like it should be simple is in fact very difficult to do well.

Web server load balancing is achieved either with a dedicated appliance like Cisco's LocalDirector line of products, through software packages like Microsoft's WLBS, or through a combination of software monitoring and round-robin DNS. There are also hybrid hardware-software packages which use a monitoring agent on the various web servers in order to determine system load or failure.

Load Balancing using DNS

Certainly the cheapest and easiest method for doing load balancing is to use some sort of roll-your-own package using DNS. Whether you use the ISC's BIND or Daniel J. Bernstein's djbdns, the basic concept is the same. You monitor hosts for load and whether they are up or not; If the load is too high or the machine is down you take them out of DNS. This works fairly well because of DNS caching, but this is also its downfall. On the plus side, you can have decentralized servers using this method. On the down side, the very thing that makes it work (DNS caching) can cause you problems with failover. Someone's system (or their ISP's DNS server) will cache the IP addresses and the client will continue going to a server which may be down.

Software-based Load Balancing

The next solution is to use a software-based load balancer like WLBS, which comes with Windows 2000 and is available for Windows NT 4.0 in the form of WolfPack. (Microsoft bought wolfpack and renamed it.) These solutions require reliable connections between web servers. All requests will go to a single IP address and traffic is redirected to other addresses. If one machine goes down, including the one which actually holds the address, others will pick it up. This provides both load balancing since WLBS will detect which machines are most heavily loaded, and failover since machines which go down are removed from the config. The downside is that all machines must be in the same facility or at sites connected via a secure dedicated link or VPN.

Load Balancing through Hardware

The final option, and perhaps the most popular, is to use a hardware load balancer. This generally provides both load balancing and failover. The simplest method of "hardware" load balancing (hardware load balancers are simply special-purpose computers, which run software of their own) is to give some percentage of the incoming connections to each server, or to pass connections off to the servers in simple round-robin style. This does not allow for failover, however. In order to do failover as well you must either periodically attempt to connect to the individual servers and remove downed systems from the configuration, or do stateful connection monitoring to determine the results of attempted incoming TCP connections.

You can also enhance hardware load balancing through the use of a software agent on the servers. These daemons will communicate with the load balancer in order to give it an idea of system load. If the communication stops, the system can be assumed to be down.