How does a website spread millions of visitors across machines?
A visitor never meets the server that answers them. A load balancer picks it, and a Windows bug once broke one cheap version of the trick.
▶ Start the storyA website spreads visitors across machines with a load balancer: a program, or a device, that stands in front of many identical servers and hands each incoming request to one of them. Load balancing is the process of distributing tasks over a set of resources so that processing is more efficient, response times improve, and no machine is overloaded while others sit idle. One of its most common uses is to provide a single internet service from multiple servers, a server farm.
The visitor never notices. A server-side load balancer listens where clients connect, forwards each request to one of the servers, and passes the reply back, so the client never knows about the machines behind it. The rules can be simple. In round robin, the first request goes to the first server, the next to the second, and so on down to the last, then it starts again. Least connections instead picks the server with the fewest active connections.
Step 1: Visitor connects
To the one address they know
Step 2: Balancer chooses
Round robin or least connections, skipping failed servers
Step 3: A server answers
One of many identical machines
Step 4: Reply goes back
The client never sees the machines behind
There is also a way to do it with no dedicated machine at all. Round-robin answers address lookups with a list of addresses for several servers that host identical services. It has a weak spot. Some resolvers re-order the list to prefer numerically closer networks, and when applied to IPv4, a bug in Windows Vista defeated round-robin load balancing altogether.
Good balancers also watch their servers. With health checking, the balancer polls servers and removes failed ones from the pool, so visitors are sent only to machines that answer. And because the balancer is itself a machine, it must not become a : balancers are usually run in high-availability pairs.
Quiz me
0/3
Recap
A load balancer picks a server for each request (round robin or least connections), checks servers' health, and is itself run in pairs.
💡 A trick to remember it · A host at the restaurant door: it seats each guest at a free table, skips closed ones, and has a backup host in case it goes home.
Surprising fact · Round-robin DNS is a load balancer with no dedicated machine, and a Windows Vista bug defeated it.
Connects to
- ☁️ How did an online store become the world's biggest renter of computers?
- ☸️ How does Kubernetes keep thousands of containers running?
- 🖥️ What is a server, and where is the cloud really?
- 🚚 How can a video reach millions of people at once without the internet buckling?
- 📖 How does your browser find a website from just its name?
- ⏳ How did a Danish telephone engineer invent the mathematics of waiting in line?
Sources (4)
No source, no claim. Every fact in this lesson (16 claims) cites at least one of these.