7 Load Balancing Algorithms Explained: How Traffic Gets Shared

Load balancing algorithms explained in plain terms means understanding how one busy website spreads millions of visitors across dozens of servers without any of them falling over. The central question is how the load balancer chooses which server gets the next request, and the answer is an algorithm: a rule that trades simplicity, fairness, and stickiness against each other.

A load balancer sits in front of a pool of servers and hands each incoming request to one of them. Done well, no server is overwhelmed while another sits idle, a failed server is quietly dropped from the pool, and a returning user lands back on the server that already knows them.

Done badly, traffic piles onto the slowest machine, sessions break, and an outage in one place becomes an outage everywhere. This article explains the seven algorithms that matter, how each one decides, and where each one earns its keep.

Key takeaways

  • A load balancer spreads requests across a pool of servers so none is overwhelmed.
  • Round robin is simple and fair only when every server and request is equal.
  • Least connections suits uneven workloads by favouring the quietest server.
  • Consistent hashing keeps the same user on the same server with minimal reshuffling.
  • The right algorithm depends on whether sessions, server sizes, or request costs vary.

Why one server is never enough

A single server has a ceiling. It can only handle so many connections, so much CPU, and so much memory before responses slow down and then stop, and it is also a single point of failure: when it goes down, the site goes down with it. Every serious service therefore runs many servers behind one address.

The load balancer is the traffic cop in front of them. It takes the flood of incoming requests and deals them out, watches the health of each server, and stops sending traffic to any that fail their checks. Users see one address and one site; behind it, a whole fleet shares the work.

The algorithm is the brain of that traffic cop. It is a small rule with large consequences, because the wrong rule can send the heaviest requests to the weakest server, or split one user’s session across machines that know nothing about each other. Our guide to reverse proxies explains the component load balancers are usually built on, and our guide to CDNs explains how traffic is spread across regions before it ever reaches one.

1. Round robin

Round robin is the simplest algorithm there is: the first request goes to server one, the second to server two, the third to server three, and then it starts again at server one. No state, no measurement, no decisions, just a turn-taking list.

Its strength is its predictability and its near-zero cost. There is nothing to compute and nothing to go wrong, and when every server is identical and every request costs about the same, it shares the load perfectly evenly. That is why it remains the default in so many setups.

Its weakness shows the moment reality intrudes. If one server is slower, or one request is a heavy report while the next is a tiny image, round robin keeps dealing evenly anyway, and the slow server falls behind while the fast one waits for work. It is fair in count, not in effort.

2. Weighted round robin

Weighted round robin fixes the obvious flaw: not all servers are equal. A beefy new machine might get a weight of three, an older one a weight of one, and the balancer deals three requests to the big server for every one it gives the small one.

This is the algorithm for fleets that grew organically, where the servers have different ages and sizes. It lets you add a powerful new machine and actually use its power, instead of watching it idle at the same share as the machine it replaced.

The catch is that weights are set by a human and go stale. A server’s real capacity depends on what else it is doing, how hot it is, and whether a neighbour is misbehaving, and a static weight knows none of that. Weighted round robin is better than plain round robin, but it is still guessing.

3. Least connections

Least connections stops guessing and looks at reality: it sends each new request to the server with the fewest active connections. A server drowning in long-running requests gets a rest, while a quiet one picks up the slack.

This shines when requests vary wildly in length. A chatty WebSocket connection that lasts an hour counts the same as a hundred quick page loads under round robin, but least connections sees the difference, because it counts what is actually open right now.

The trade is a little more bookkeeping and a subtle trap: a server with few connections might have few because it is slow to answer, not because it is idle. Most implementations therefore track response times as well, and the best ones blend the two.

4. Least response time

Least response time goes one step further and picks the server that is answering fastest, combining how busy it is with how quickly it responds. A server that is struggling shows up as slow, so traffic drifts away from it before it fails outright.

This is the most adaptive of the simple algorithms, and it behaves well under uneven load. It also protects users directly, because it optimises for the thing they actually feel: how long they wait for an answer.

The risk is herd behaviour. If every balancer in a fleet notices the same fast server at once, they all pile onto it, and it stops being fast. In practice the effect is damped by the fact that response times are sampled, not continuous, but it is a real failure mode to watch for.

A photograph of a busy airport departures board and travellers splitting between check-in desks in a modern terminal
A photograph of a busy airport departures board and travellers splitting between check-in desks in a modern terminal shows the load balancer’s job: spread the queue so no single desk is overwhelmed.

5. IP hash

IP hash takes the client’s address, runs it through a hash function, and uses the result to pick a server. The same client always lands on the same server, which is exactly what you want when the server keeps session data in memory.

This is session persistence without cookies and without a shared session store. A shopping basket, a login, or a game state lives on one machine, and the client keeps coming back to it, so nothing needs to be copied anywhere.

The price is unevenness. Hashing does not guarantee an even spread, and if one server dies, its clients are rehashed across the survivors, which can shuffle more sessions than you would like. It is a good fit for stateful services, and a poor one for anything where balance matters more than stickiness.

6. Consistent hashing

Consistent hashing solves IP hash’s reshuffle problem. Servers are placed on a virtual ring, and each client maps to the nearest server clockwise around it, so adding or removing a server only moves the clients nearest to it on the ring, not everyone.

This is the algorithm behind distributed caches and many key-value stores. When a cache node joins or leaves, only a small fraction of keys move, which keeps the cache warm and the disruption small, and that matters enormously at scale.

The cost is complexity. A naive ring can be badly unbalanced, so real systems use many virtual nodes per server to smooth it out, and the implementation is fiddlier than a round robin list. For a small pool it is overkill; for a large, changing one it is essential.

7. Least bandwidth and custom rules

Least bandwidth picks the server using the least network throughput, which suits streaming and file delivery, where one connection can dwarf a thousand others in bytes. Counting connections would miss the point entirely when a single video stream outweighs a whole crowd of page views.

Beyond that, many balancers let you write your own rules: route by URL path, by header, by geography, or by the result of a health check. An image service might send thumbnails to one pool and uploads to another, and a global balancer might send European users to Frankfurt and Asian users to Singapore.

Custom rules are powerful, but they are also a way to build a system nobody else understands. The rule of thumb is to start with a standard algorithm, add a custom rule only for a measured problem, and write down why it exists. Our guide to API gateways explains a related component that routes by request content.

Comparing the seven algorithms

Choosing between them is a matter of what varies in your system. If nothing varies, round robin is enough. If servers differ, weight them. If requests differ, measure connections or response time. If sessions matter, hash.

The table below sets out the trade-offs at a glance.

Algorithm Decision based on Session stickiness Best for
Round robin Turn-taking None Identical servers, even requests
Weighted round robin Turn-taking with weights None Mixed server sizes
Least connections Active connections None Long-lived, uneven requests
Least response time Speed and load None Latency-sensitive services
IP hash Client address Yes Stateful sessions
Consistent hashing Hash ring position Yes Caches, changing fleets
Least bandwidth Throughput used None Streaming and file delivery

The practical result is that most services start on round robin or least connections, add stickiness only when sessions demand it, and reach for consistent hashing when the fleet itself keeps changing.

Load balancing checklist

  • Start with round robin or least connections and measure before optimising.
  • Use health checks so dead servers leave the pool automatically.
  • Add stickiness only when sessions genuinely live on one server.
  • Weight servers when the fleet has mixed hardware.
  • Test what happens when a server fails mid-traffic.
  • Watch for uneven spreads after a deploy changes the pool.
  • Prefer least connections when request lengths vary widely.
  • Keep the balancer itself redundant, or it becomes the single point of failure.
  • Log which server handled each request for debugging.

Frequently asked questions

What is a load balancing algorithm?

It is the rule a load balancer uses to choose which server in a pool receives each incoming request, balancing fairness, speed, and session stickiness.

Which load balancing algorithm is best?

There is no universal best. Round robin suits identical servers, least connections suits uneven workloads, and hashing suits stateful sessions, so the right choice depends on your traffic.

What is the difference between round robin and least connections?

Round robin deals requests out in turn regardless of load, while least connections sends each request to the server with the fewest active connections, which adapts to uneven work.

Why does session stickiness matter?

Because some servers keep session data in memory, so a user whose requests jump between servers can lose their login or their shopping basket.

What is consistent hashing?

A hashing scheme that places servers on a ring, so adding or removing one only reassigns the clients nearest to it, instead of reshuffling everyone.

Do I need a load balancer for a small site?

Not at first. One server is fine until traffic or reliability demands more, and at that point a simple round robin balancer is the usual first step.

The bottom line

Load balancing algorithms explained in one line is this: pick the rule that matches what varies in your system, and let the balancer do the rest.

Most of the time that means round robin or least connections, with hashing only when sessions demand it, and the fancy options kept for the day the fleet itself starts changing shape.

This article is general information about how load balancing algorithms work, not advice about configuring one for a particular system.

Latest articles

Scroll to Top