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.

The new request goes to the shortest queue
The new request goes to the shortest queue

The balancer counts connections still open on each server and picks the smallest count. A slow server holds its connections longer, so it gets fewer new ones, without the balancer knowing why it is slow.

Least connections is a load-balancing rule: each new request goes to the backend with the fewest connections still open. Round robin gives every backend its turn, so a slow server's unfinished work piles up; least connections (HAProxy balance leastconn) steers away from it without knowing why it is slow. Both respect weights: a backend with weight 2 gets twice the share.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab