Working rules for load balancing

Every team builds up a private set of habits around load balancing. These are ours, with the reasons behind them.

The Lessons

  1. We take a backend out of rotation first and wait a couple of seconds for in-flight requests to complete ahead of stopping the process.

  2. Where a few requests last ages and the rest next to nothing, handing new work to the emptiest backend evens out the load better than naive round robin.

  3. A liveness check should exercise the path users need, not just whether the process is running.

Two of these rules can be seen in the liveness check we use, reproduced below as it stands:

curl -fsS -m 2 http://127.0.0.1:3436/livez
# the balancer checks every 20s, marks a backend down after 3 failures
# and up again after 2 passes