The problem: one server, all the traffic
If every visitor to your app is handled by a single server, that server eventually runs out of room (CPU, memory, open connections) while everything else you've paid for sits idle. Past a certain point, it doesn't get slower gracefully; it stops responding at all.
What a load balancer actually does
A load balancer sits in front of a group of identical servers and decides, for each incoming request, which one should handle it, based on who's least busy, or simply taking turns. The client never talks to a specific server directly; it talks to the load balancer, which routes the request onward.
A few common strategies
Round robin just takes turns, server one, two, three, one again. Least connections sends the next request to whichever server currently has the fewest active requests. Fancier setups factor in server health, response time, or geography.
The catch: state
If a server remembers something about you between requests, like your logged-in session, and the next request lands on a different server that doesn't know you, things break. This is why systems either keep servers stateless (session data lives elsewhere, shared) or use “sticky sessions” to keep a user on the same server.
Written by
The Docerity teamEngineers who explain for a living