Skip to content
StackDecode
System Design
8. Load Balancing and ScalabilityAnimated

Least Connections

Send to the server with fewest active connections.

The idea

Adapts to uneven request durations by tracking connection counts.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

10.0.0.4Load balancerServer 11 totalServer 20 totalServer 30 total
  • chosen path
  • active connections (bar)

Request 1 goes to server 1: it has the fewest active connections (0).

request:
1
server:
1
1/14

The white bar inside each server is its current number of active connections.

Step by step

  1. 1Track connections per server
  2. 2Pick the lowest
  3. 3Forward the request
  4. 4Update counts when done

Where it is used

Long-lived or varied requests.

Watch out for

Fewest connections is not always lowest load.

Related