Hi again,

On Sat, Dec 15, 2018 at 05:09:07PM +0100, Willy Tarreau wrote:
> Hi Norman,
> 
> On Thu, Dec 06, 2018 at 04:57:18PM +0000, Norman Branitsky wrote:
> > NGINX just announced the following load balancing method as default for 
> > their Ingress Controller for Kubernetes.
> > Will this appear on the HAProxy roadmap?
> 
> That's interesting because we've had a discussion about this very same
> algo not too long ago with a coworker. I said that it should be trivial
> to implement, though I think that it might make sense to make the number
> of tries configurable. Indeed, I need to read the complete thesis on it
> but I suspect it can make sense to take more than 2 tries if the number
> of servers and/or LB nodes (or the product of the two) is very high. Maybe
> we'll end up picking log()+1 or something like this.
> 
> But yes that's definitely very interesting.

So yesterday I've implemented this as intended with the ability to configure
the number of tries. I've spent quite some time studying the thesis, and it
clearly explains that the primary purpose of the algorithm is to provide an
almost equivalent of our leastconn algorithm for situation where figuring
what server is the least loaded is expensive.

I've ran some quick comparative tests with 2.0-dev on a 20-server farm,
and it's interesting :
  - the single random is uneven between servers in terms of maximum
    experienced load, which varies by almost +/-50%, though the total
    number of requests is roughly fair ;

  - the power-of-two random is way better in that the difference
    between the least loaded and the most loaded servers varies by
    around +/-10% ;

  - the leastconn algo is even better because the maximum load experienced
    by all servers is exactly the same among the farm, and this max is
    about 30% lower than with power-of-tow ;

I may run a more detailed test eventually.

Nevertheless, I merged it and changed the random algo to make two draws
by default because it behaves much better this way, and this will have
an impact in distributed environments where people used to prefer to
use random over any other for whatever reason, taste, or belief.

This would be very easy to backport to 1.9 in case there's interest in
having it there. Given that the random algorithm was introduced with 1.9
it's unlikely that anyone has yet made their opinion on it ;-)

Cheers,
Willy

Reply via email to