More than 10 years ago, people discovered they could connect multiple cheap machines to perform computing tasks that would normally require a mainframe or supercomputer. NASA’s Beowulf cluster was an early example that is still in use today (http://www.beowulf.org). A Wikipedia entry (http://en.wikipedia.org/wiki/Computer_cluster) lays out the chief characteristics of a cluster succinctly:
A computer cluster is a group of loosely coupled computers that work together closely so that in many respects they can be viewed as though they are a single computer. Clusters are commonly, but not always, connected through fast local area networks. Clusters are usually deployed to improve speed and/or reliability over that provided by a single computer, while typically being much more cost-effective than single computers of comparable speed or reliability.
Clusters are a good solution when you’re looking to improve speed, reliability, and scalability for a reasonable price. Amazon, Yahoo!, and Google have built their businesses on thousands of commodity servers in redundant cluster configurations. It’s cheaper and easier to scale out (horizontally, by just adding more servers) than it is to scale up (vertically, to more expensive machines). There are many Linux cluster solutions, both open source and commercial. In this chapter we’ll discuss clusters based on the free Linux Virtual Server (http://www.linuxvirtualserver.org). We’ll show how to combine cereal boxes, rubber bands, and three computers into a load-balanced Apache web server cluster. We’ll also discuss high availability and, finally, alternatives to clusters. We won’t cover high-performance computing clusters, grid computing, parallelization, or distributed computing; in these areas, hardware and software are often specialized for the subject (say, weather modeling or graphics rendering).
Load Balancing and High Availability
Load balancing (LB) provides scalability: the distribution of requests across multiple servers. LB consists of packet forwarding plus some knowledge of the service being balanced (in this chapter, HTTP). It relies on an external monitor to report the loads on the physical servers so it can decide where to send packets.
High availability (HA) provides reliability: keeping services running. It relies on redundant servers, a heartbeat exchange to say “I’m still alive,” and a failover procedure to quickly substitute a healthy server for an ailing one.
In this chapter, we’re mainly concerned with LB, which administrators will generally encounter first and need more often. As sites become more critical to an organization, HA may also become necessary. Toward the end of this chapter, we’ll provide some useful links for information on setting up combined LB/HA systems.
The example LB configuration we’ll use in this chapter is a simple one consisting of three public addresses and one virtual address, all listed in Table 7-1 .
Table 7-1. Addresses and roles for servers in our cluster
Name
IP address
Description
lb
70.253.158.44
Load balancer—public web service address
web1
70.253.158.41
First web server—one of the real IPs (RIPs)
web2
70.253.158.45
Second web server—another RIP
(VIP)
70.253.158.42
Virtual IP (VIP) shared by lb, web1, and web2, in addition to their real IP addresses
The VIP is the address exposed to external clients by the load balancer, which will relay requests to the web servers.