Try
↑ ↓ move↵ openesc close
In this lesson · topic 2 of 7
  1. 1. Why queues form
  2. 2. Four ways to pick a server
  3. 3. Race four strategies on one arrival stream
  4. 4. Why light load hides a bad balancer
  5. 5. The knee in the queueing curve
  6. 6. Fan-out turns a 1 percent tail into 63 percent
  7. 7. Pick the strategy for the fleet

Topic 2

Four ways to pick a server

4 min read

The decision

A balancer makes one decision per request: which server gets it. The strategies differ in how much they look at before deciding. Step through one decision below. The five servers have the queues shown, and the same request is placed by each strategy.

One request, four strategies

Step 1 / 5
4S11S23S30S46S5new requestdashed: looked at. solid: chosen.grey frames: earlier picks.
queues
4 1 3 0 6
  1. A request arrives

    Five servers have these queues. The balancer must pick one for the new request, and the request will wait behind whatever is already there.

What each strategy needs

Round robin keeps a counter and walks through the servers in order. It needs no information about the servers, and it spreads request counts perfectly evenly. But it counts requests, not work. If requests differ in cost, or servers differ in speed, even counts are not even load.

Random is the same idea with a coin flip instead of a counter. It needs nothing, and it has no memory, so it cannot avoid a server it just overloaded.

Least connections asks every server how many requests it has right now and picks the smallest. It reacts to real load, including slow servers and expensive requests. The price is a fresh count from every server before every decision. With many servers or many balancers, that is a lot of coordination, and the counts go stale the moment they are read.

Power of two choices picks two servers at random and takes the shorter queue. It asks two servers, not all of them. The idea comes from research on balls and bins, where a second random choice turns out to be worth far more than the cost of one extra lookup. The sources listed at the end of this lesson go through the proof.

What the lab adds

In the lab every strategy faces the same arrivals. Each request arrives at the same instant with the same cost no matter which strategy runs, and only the placement differs. That is what makes the comparison fair, and it is why you can read the difference in p99 as the effect of the strategy alone.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms