The simplest form of load balancing is round-robin DNS, where multiple A records are defined for the same name; this results in the servers taking turns responding to any incoming requests. This doesn’t work well if a server fails, though, and it doesn’t take into account any special needs the service may have. With HTTP, for example, we might need to maintain session data such as authentication or cookies and ensure that the same client always connects to the same server. To meet these needs, we’ll get a little more sophisticated and use two tools:
IP Virtual Server (IPVS), a transport-level (TCP) load-balancer module that is now a standard Linux component
ldirectord, a utility that monitors the health of the load-balanced physical servers
The installation instructions are based on the Debian 3.1 (Sarge) Linux distribution.
IPVS on the Load Balancer
Since IPVS is already in the Linux kernel, we don’t need to install any software, but we do need to configure it.