]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: lb-chash: add directive hash-preserve-affinity
authorPierre-Andre Savalle <psavalle1@protonmail.com>
Fri, 21 Mar 2025 10:27:21 +0000 (11:27 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 25 Mar 2025 17:01:01 +0000 (18:01 +0100)
commit8ed1e91efdb9fc9e5a988b615b09e3e6fa32715a
treedeec8b909a477d53ab167d614e5aab0be412277d
parentcf9e40bd8a1414ad2135e04ed8764effadc96be8
MEDIUM: lb-chash: add directive hash-preserve-affinity

When using hash-based load balancing, requests are always assigned to
the server corresponding to the hash bucket for the balancing key,
without taking maxconn or maxqueue into account, unlike in other load
balancing methods like 'first'. This adds a new backend directive that
can be used to take maxconn and possibly maxqueue in that context. This
can be used when hashing is desired to achieve cache locality, but
sending requests to a different server is preferable to queuing for a
long time or failing requests when the initial server is saturated.

By default, affinity is preserved as was the case previously. When
'hash-preserve-affinity' is set to 'maxqueue', servers are considered
successively in the order of the hash ring until a server that does not
have a full queue is found.

When 'maxconn' is set on a server, queueing cannot be disabled, as
'maxqueue=0' means unlimited.  To support picking a different server
when a server is at 'maxconn' irrespective of the queue,
'hash-preserve-affinity' can be set to 'maxconn'.
doc/configuration.txt
include/haproxy/proxy-t.h
reg-tests/balance/balance-hash-maxconn.vtc [new file with mode: 0644]
reg-tests/balance/balance-hash-maxqueue.vtc [new file with mode: 0644]
src/lb_chash.c
src/proxy.c
tests/conf/test-hash-preseve-affinity.cfg [new file with mode: 0644]