All the basics

What is a load balancer?

A load balancer stands in front of several servers and shares incoming requests among them, skipping any server that is down.

A traffic cop at a junction: every arriving car is waved into one of several lanes, and a blocked lane is skipped.

Press Play to watch it run · 5 steps

Without a balancer one server takes the whole crowd and falls over. With one, requests are shared and a dead server is skipped.

One server versus a load balancerWithout a balancer one server takes the whole crowd and falls over. With one, requests are shared and a dead server is skipped.UsersLoad balancerServer AServer BServer C

Tap any box to see what it is and what it talks to.

  • Client
  • Load balancer
  • Service
Open in playground
Text description
  1. Every user is sent to Server A, and a big crowd arrives.
  2. The line of waiting requests keeps growing.
  3. Replies get slower and slower.
  4. Server A runs out of memory and crashes. The site is down.
  5. New users get errors, while two spare servers sit idle.
  • One server has a limit, and a crowd can break it.
  • A load balancer shares requests across many servers.
  • It checks health and stops sending traffic to dead servers.

Reach for it when

When one server cannot carry the traffic, or its crash would take the site down. Not for a one-server hobby app.

The catch

Everything flows through it, so if the only balancer dies, three healthy servers become unreachable. Run two.

Say it in an interview“I would put a load balancer in front of stateless servers. It spreads traffic, health-checks them, and lets us add servers or lose one without downtime.”