Concepts / Load balancing

Load balancing

Least connections

Also called leastconn, balancing algorithm, weight, weighted round robin

A balancing policy that sends each new request to the backend with the fewest connections still open.

Round robin gives every backend its turn, so when requests cost unequal amounts a slow server's unfinished work piles up. Least connections (HAProxy balance leastconn) counts the open connections instead, and steers new requests away from a busy server without knowing why it is slow. Both respect weights: a backend with weight 2 gets twice the share, and a weight that does not match the hardware starves some servers and overloads others.

See it on real machines

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Start with a free account: Google or email, no card.

Open this lab