Three servers, one IP: who gets the next request?
FotoFlow scaled to three servers, but users only know one DNS address, so every request still lands on Server B while A and C sit idle. The extra hardware bought nothing: adding servers only helps if traffic actually reaches them.
One front door
A load balancer becomes the one public address of the service. Clients connect to it, it forwards each request to one of the servers behind it, and relays the answer back. The servers behind it are called its pool, and they can now come and go without clients ever knowing.
Who gets the next request
The simplest rule is round robin: A, then B, then C, then A again. Cheap and fair, as long as the servers are equally powerful and every request costs the same. Weighted round robin gives bigger servers a bigger share.
But real traffic is lumpy: loading a page takes 5 ms, exporting a year of photos takes 5 seconds. Round robin counts requests, not work, and if the heavy ones land on B by luck of the rotation, B drowns while A and C coast. Round robin has no idea how busy a server actually is.
The fix is least connections: the balancer tracks how many requests each server is busy with and sends the next one to the least busy. A server stuck on slow work holds more open connections, so it automatically receives less new work. Other strategies include least response time, IP hash for same-client-same-server, and power of two choices.
Routing around the dead
Every few seconds the balancer probes each server with a health check such as GET /health. A server that misses several checks in a row is pulled from the pool until it recovers. Server C can crash and no user notices. Health checks plus spare servers mean no single server is a single point of failure any more.
Who balances the balancer?
Removing one single point of failure created another: when the balancer dies, everything behind it is unreachable. Anything that every request depends on must itself be redundant. The standard answer is two load balancers, an active one and a passive standby, sharing a virtual IP and exchanging heartbeats every second. When the active dies, the standby claims the virtual IP within seconds and clients keep using the same address. Cloud balancers do this for you across machines and zones.
Reading the request: layer 4 and layer 7
A layer 4 balancer sees only IP addresses and ports and forwards whole connections. A layer 7 balancer reads the HTTP request itself, so it can route by path: /api/* to the API servers, /images/* to a separate image service, each pool scaled and deployed on its own. Layer 7 also terminates TLS and can add caching or compression.
Layer 7 is what makes zero-downtime deploys possible. In a rolling deploy the balancer drains one server at a time, no new requests but in-flight ones finish, then updates it, waits for the health check, and rejoins it. Blue-green goes further: bring up a full new pool and switch the balancer over at once, and back if anything looks wrong.
What this does not solve
The balancer now spreads requests blindly across servers, which exposes a hidden assumption: that any server can handle any request. The moment Alice's login session lives in one server's memory, round robin itself becomes the bug. That is the next post.
If you removed your load balancer today, how many minutes would users notice, and what would they see?
Does your heaviest endpoint cost roughly the same as your lightest one? If not, which balancing rule are you relying on right now?
One front door, many rooms behind it.
Next in the series: Why does login break the moment you add a second server?
Sources
System Design Primer
MDN Web Docs: HTTP redirections
undefined
Google SRE Books
Recommended for you
- Craft & Skills
One server, 10 million users: how does a photo app survive that?
A 40-post series that follows FotoFlow, a photo app, from one server and 100 users to 10 million users with direct messages. One problem, one fix, one honest cost at a time.
- Craft & Skills
Ten million users want direct messages: could you design the chat system?
The final design: 20 million open sockets and a promise that every message arrives, in order, exactly once. Dumb gateways, a connection registry, store-first durability and sync by cursor.
- Craft & Skills
Five million home feeds: how do you build the page everyone opens?
The home feed must load in 200 ms from two hundred followed accounts. Fan-out on read melts at 4.6 million lookups a second; fan-out on write melts on celebrities; the hybrid survives both.
- Craft & Skills
FotoFlow wants short share links: could you design one today?
The first full design walkthrough: turn a one-line brief into numbers, the simplest system, then fix codes, caching, storage and abuse one bottleneck at a time. The method is the point.
Enjoyed this article?
Subscribe for new articles. No spam. Unsubscribe anytime.
Typed live, never pasted.