System Design 101Read the flowThe load balancer spreads requests and stops sending traffic to a server that fails. Round robin fits uniform work. Least connections helps uneven work. Hashing keeps a key on one server.
Free · no account requiredLesson 3 of 9
Load balancing
Spread traffic across many servers so none is overwhelmed and any can fail.
Visual model
One door, several healthy servers
What it buys you
A load balancer sits in front of a pool of servers and distributes incoming requests across them.
This unlocks horizontal scaling and zero-downtime deploys. Add servers for capacity or drain one before a release.
Health checks provide fault tolerance by removing dead instances from rotation.
Layer 4 balancers route by IP and port. Layer 7 balancers understand HTTP and can route by path, header or cookie.
Algorithms and stickiness
How requests get assigned matters for fairness and correctness.
- Round-robin: rotate through the servers. It works when requests are similar.
- Least-connections: choose the least-busy server. It fits long-lived or uneven requests.
- Consistent hashing: map a key, such as a user ID, to a server. The same key reaches the same node and fewer keys move when nodes change.
- Sticky sessions pin a user to one server. They weaken balancing and break when that server dies. Prefer stateless servers with shared session storage.
See it
The routing rule changes the result
Key takeaways
- Load balancing is the prerequisite for horizontal scaling and high availability.
- Keep servers stateless so any instance can serve any request and failover is trivial.
- Health checks are mandatory. Without them, traffic may reach dead nodes.