Home

LeastConnections

Least connections is a load-balancing algorithm used by reverse proxies and application delivery controllers. It routes each new client connection to the backend server that has the fewest active connections at the moment the request arrives. The idea is that a server with fewer active connections is likely to become available sooner, reducing overall wait time.

Implementation typically involves the load balancer maintaining a per-backend count of active connections, updated when connections

Commonly used in HTTP and TCP load balancing, least connections is supported by many popular proxies and

Advantages include better handling of long-lived connections and dynamic workloads, as well as responsiveness to real-time

are
opened
and
closed.
Some
systems
support
weighted
least
connections,
where
servers
have
assigned
capacities
and
the
algorithm
selects
the
least-loaded
server
within
those
weights.
When
multiple
servers
share
the
same
minimal
connection
count,
ties
are
resolved
by
randomness
or
by
a
secondary
method
such
as
round
robin.
load
balancers.
For
example,
Nginx
provides
a
least_conn
option
in
upstream
configurations,
while
HAProxy
offers
balance
leastconn.
LVS
and
other
load-balancing
solutions
may
also
implement
this
method
or
variants
of
it.
load
rather
than
relying
solely
on
static
distribution.
Disadvantages
include
the
potential
to
ignore
non-connection-based
resource
usage
(CPU,
memory),
possible
skew
when
connection
durations
vary
greatly,
and
the
need
for
accurate
tracking
of
active
connections.
Weights
and
health
checks
are
commonly
used
to
mitigate
these
issues
and
adapt
the
algorithm
to
heterogeneous
server
pools.