Hi Dmitry,

On Fri, Mar 07, 2014 at 12:16:32PM +0400, Dmitry Sivachenko wrote:
> 
> On 06 ?????????? 2014 ??., at 19:29, Dmitry Sivachenko <[email protected]> 
> wrote:
> 
> > Hello!
> > 
> > I am using haproxy-1.5.22.
> > 
> > In a single backend I have servers with different weight configured: 16, 
> > 24, 32 (proportional to the number of CPU cores).
> > Most of the time they respond very fast.
> > 
> > When I use balance leastconn, I see in the stats web interface that they 
> > all receive approximately equal number of connections (Sessions->Total).
> > Shouldn't leastconn algorithm also honor weights of each backend (to pick a 
> > backend with minimal Connections/weight value)?
> > 
> > Thanks.
> 
> I mean that with balance leastconn, I expect the following behavior:
> -- In ideal situation, when all backends respond equally fast, it should be
> effectively like balance roundrobin *honoring specified weights*;
> -- When one of the backends becomes slow for some reason, it should get less
> request based on the number of active connections
> 
> Now it behaves almost this way but without  "honoring specified weights".

We cannot honnor both at the same time. Most products I've tested don't
*even* do the round robin on equal connection counts while we do. I'm just
restating the point I made in another thread on the same subject : leastconn
is about balancing the active number of connections, not the total number of
connections. So the total number of connections is totally meaningless here,
what counts is only the number of active ones. Leastconn ensures the fastest
response time is always met for short sessions, and the best balance is
achieved for long sessions. 

If you're counting the total number of connections, then you're using the
wrong algorithm. Leastconn is for memory-bound servers. Roundrobin is for
CPU-bound servers.

Willy


Reply via email to