1-min guide

Load balancers and health checks

A load balancer is a device that spreads lots of requests across several servers so that no single server gets overloaded.

Reading time: about 1 min

More in the 5-min version →

In the game, this was a supermarket checkoutPlay “Checkout Line Captain”

In the gameIn real IT
ShoppersRequests
Checkouts 1–3Three web servers
Slow trainee’s checkoutA weaker server
“Closed” signA failure found by a health check
Flash saleTraffic spike
Line captainLoad balancer
RequestsLoadbalancerweb01 OKweb02 OKweb03 NG×web03 doesn’t answer the health check → no traffic
Servers that don’t answer the health check are automatically taken out of rotation

How does it distribute?

There are three typical methods: round robin, which hands requests out one at a time in turn; least connections, which sends to the server with the fewest requests in progress right now; and weighting, which gives more to higher-performance servers. When an old, weak server is in the mix, weighting gives it less.

Health checks find failures

A load balancer regularly asks each server “are you OK?” (a health check). It stops sending to servers that don’t answer. So even if one breaks, the remaining servers keep the service running.

Get stronger by adding servers

When traffic grows, you add servers and line them up behind the load balancer. This is called scaling out. Unlike scaling up, which makes one server more powerful, its strength is that you can keep adding machines.

Summary
  • A load balancer spreads requests across several servers
  • Health checks remove failed servers
  • Scaling out — adding servers — raises capacity
Go further: 5-min deep diveLoad balancing in depth: session persistence, L4 vs. L7 and redundancyWhich server do logged-in users go to? Can it route by URL? What if the load balancer itself breaks?Read the 5-min version →