Re: roundrobin vs leastconn

From: Willy Tarreau <w#1wt.eu>
Date: Fri, 17 Jun 2011 20:32:01 +0200


On Fri, Jun 17, 2011 at 02:22:34PM -0400, James Bardin wrote:
> This is more for my own curiosity (I'm not advocating a change in the
> haproxy defaults) -
> Is there any inherit drawback to always using leasconn instead of
> roundrobin? Since it uses roundrobin internally when servers are
> equally loaded, it seems that this would be the most fair algorithm in
> most cases, even in plain http where it avoids servers hit with a
> number of slow connections.

The round robin of the leastconn will not apply weigths, it's only used between servers which have the exact same amount of connections in order to avoid the common syndrom of the low load always hitting the same server because there's either 0 or 1 connection.

Also there are situations where you really want to ensure that only round robin will be used. For instance, if you place your visitors on servers and then do cookie-based persistence, you absolutely want to ensure the smoothest possible distribution, which round robin achieves. If you'd do leastconn on that, sometimes you'd place a user on an apparently less loaded server at the moment you have to select the server, resulting in an imbalance between all servers.

I tend to recommend leastconn only when long sessions are being used (eg: TSE, WebSocket, MySQL, connection pools, etc...).

Regards,
Willy Received on 2011/06/17 20:32

This archive was generated by hypermail 2.2.0 : 2011/06/17 20:45 CEST