Skip to content

Introduction to load balancing algorithms

The load balancer article named the four common algorithms in passing — round robin, least connections, IP hash, and weighted variants — while explaining what a load balancer is and how L4 versus L7 designs differ. That was necessarily a summary: a load balancer's entire job description compressed into one section. The four articles in this module take each of those algorithms in turn and go one level deeper — not just what each one does, but the actual selection logic, the specific failure mode each one is prone to, and the concrete situation that makes one algorithm clearly the right pick over the others.

Why the choice of algorithm is a real decision, not a default to leave alone

Every algorithm in this module answers the identical question — given several healthy backends, which one gets the next connection or request? — and every one of them gets that answer right under some conditions and wrong under others. NGINX's own documentation lists round robin as its default method specifically because it needs no configuration to enable, not because it's the best fit for every backend pool; a pool of identically sized servers handling uniformly cheap requests is exactly the case default round robin was built for, and it stops being the right choice the moment either of those assumptions breaks.

That's the throughline across all four articles: an algorithm is a bet about what the traffic and the backends look like, and the wrong bet doesn't usually fail loudly. It fails as an uneven CPU graph across otherwise identical servers, a support ticket about a user getting logged out for no reason, or a newly added, more powerful server sitting nearly idle while its older neighbors stay pegged — symptoms that point back to the algorithm's assumptions being wrong for this specific deployment, not to a bug in the load balancer itself.

What ties the four together

All four algorithms operate at the same point in a request's life: after a load balancer — Layer 4 or Layer 7, as the load balancer article distinguished — has already decided the incoming connection is legitimate and has a pool of currently healthy backends to choose from, courtesy of the same health-check mechanism already covered there. None of these four articles revisit health checks or the L4/L7 distinction; each one assumes a healthy backend pool already exists and focuses entirely on which member of that pool gets picked next, and why.

Read in order — Round Robin, then Least Connections, then the Weighted algorithm, then IP Hash — the four build a genuine comparison: each new algorithm exists specifically to fix a weakness the previous one has, and by the end it's possible to look at a real backend pool and a real traffic pattern and say, concretely, which one fits.

Sources