Tech●●●●●Difficulty 3 of 5

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 story

A 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.

A request through a load balancer
  1. Step 1: Visitor connects

    To the one address they know

  2. Step 2: Balancer chooses

    Round robin or least connections, skipping failed servers

  3. Step 3: A server answers

    One of many identical machines

  4. 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

  1. 1.How does round-robin scheduling choose a server?
  2. 2.Why are load balancers usually run in high-availability pairs?
  3. 3.What is the downside of "sticky" sessions?

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.

Sources (4)

No source, no claim. Every fact in this lesson (16 claims) cites at least one of these.

  1. [1]Load balancing (computing) · Wikipedia
  2. [2]Round-robin DNS · Wikipedia
  3. [3]Amazon Web Services · Wikipedia
  4. [4]Kubernetes · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗