]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: backend: implement random-based load balancing
authorWilly Tarreau <w@1wt.eu>
Thu, 3 May 2018 05:20:40 +0000 (07:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 3 May 2018 05:20:40 +0000 (07:20 +0200)
commit760e81d35606b487b5a1ada47ebaa58bc9a25b52
tree9268d41d6c962abbacd6d407a725e207bb31783f
parentfe971b35aeca9994f3823112c783aa796e74075a
MINOR: backend: implement random-based load balancing

For large farms where servers are regularly added or removed, picking
a random server from the pool can ensure faster load transitions than
when using round-robin and less traffic surges on the newly added
servers than when using leastconn.

This commit introduces "balance random". It internally uses a random as
the key to the consistent hashing mechanism, thus all features available
in consistent hashing such as weights and bounded load via hash-balance-
factor are usable. It is extremely convenient because one common concern
when using random is what happens when a server is hammered a bit too
much. Here that can trivially be avoided, like in the configuration below :

    backend bk0
        balance random
        hash-balance-factor 110
        server-template s 1-100 127.0.0.1:8000 check inter 1s

Note that while "balance random" internally relies on a hash algorithm,
it holds the same properties as round-robin and as such is compatible with
reusing an existing server connection with "option prefer-last-server".
doc/configuration.txt
include/types/backend.h
src/backend.c
src/cfgparse.c