Loading…
Loading…
Charting your lesson…
Opening your lesson…
Load Balancing
Lesson 2 of 4
6 steps•about 11 min•10 flashcards
Step 1/ 61 min
The moment you scale horizontally, you need something to spread requests across your servers — that's the load balancer. It's a fixture of nearly every system-design answer, so you should be able to explain what it does, name a couple of routing algorithms, and mention health checks without hesitating. Skipping the load balancer in a design that has multiple servers is an immediate red flag.
What this covers / why it matters: what a load balancer does, common algorithms, health checks, and how it enables reliable horizontal scaling. Small topic, near-guaranteed to come up.
Step 2/ 61 min
A load balancer sits in front of your servers and distributes incoming requests across them. It gives you three things at once: spread load (no single server is overwhelmed), high availability (route around a server that dies), and a single entry point (clients hit one address; servers can be added/removed behind it invisibly).
| Algorithm | How it routes |
|---|---|
| Round robin | Each request to the next server in turn — simple, even spread |
| Least connections | To the server with the fewest active connections — good for uneven request durations |
| Weighted | More traffic to more powerful servers |
| IP hash | Same client IP always to the same server — a way to keep session affinity |
Pair this with health checks: the balancer periodically pings each server and stops routing to any that fail, then resumes when they recover. That's what turns "a server crashed" into a non-event for users.
Step 3/ 61 min
"You have three app servers. How do requests reach them reliably?"
"I'd put a load balancer in front as the single public entry point. It distributes requests across the three servers — round robin is a fine default, or least-connections if request durations vary a lot. Critically, it runs health checks: it pings each server every few seconds, and if one stops responding it's pulled out of rotation automatically, so users just get served by the healthy two — no downtime. When the server recovers and passes health checks again, it's added back. For this to work cleanly the servers should be stateless, so any of them can handle any request; if I were forced to keep state on the servers I could use sticky sessions via IP hash, but I'd prefer shared session storage instead. For high availability I'd also run the load balancer itself redundantly, so it isn't a new single point of failure."
Covers distribution, algorithm choice, health checks, statelessness, and even the balancer's own redundancy.
Step 4/ 61 min
Step 5/ 61 min
Drawing several servers with no load balancer, or adding one but forgetting health checks. Without health checks the balancer keeps sending traffic to a dead server, so users see errors. The whole point is automatic failover — always pair the balancer with health checks.
Step 6/ 6· Worked examples1 min
Problem/Question: "You have five identical app servers. Explain how a load balancer distributes traffic and which algorithm you'd pick."
Solution/Model answer:
Role: a load balancer (LB) sits between clients and servers, spreading requests to avoid overloading any node, and improving availability by routing away from unhealthy servers (via health checks).
Common algorithms:
Recall
Keep this
A load balancer (LB) sits in front of your servers and distributes incoming requests across them. It is what makes horizontal scaling actually work — and it removes single points of failure by routing around dead servers via health checks.
| Concept | Detail |
|---|---|
| Algorithms | Round-robin, least-connections, IP-hash (sticky), weighted |
| Layer | L4 (transport, fast) vs L7 (HTTP-aware, can route by path) |
| Health checks | LB pings servers; stops routing to unhealthy ones |
| Sticky sessions | Same client → same server (needed if state is local) |
| Redundancy | The LB itself is made HA (active-passive pair) |
Expected pattern: Appears the moment you add a second server; interviewers ask which algorithm and how health checks work.
Quick recap: LB spreads requests (round-robin/least-conn), uses health checks to skip dead servers, works best with stateless servers, and must itself be HA.
You've read 0 of 6 steps
Now lock it in — questions straight after reading are what make it stick.