mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-20 21:31:28 +02:00
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'.
53 lines
955 B
INI
53 lines
955 B
INI
# This is a test configuration for "hash-preserve-affinity" parameter
|
|
global
|
|
log 127.0.0.1 local0
|
|
|
|
defaults
|
|
mode http
|
|
timeout client 10s
|
|
timeout server 10s
|
|
timeout connect 10s
|
|
|
|
listen vip1
|
|
log global
|
|
option httplog
|
|
bind :8001
|
|
mode http
|
|
maxconn 100
|
|
balance url_param foo
|
|
server srv1 127.0.0.1:80
|
|
server srv2 127.0.0.1:80
|
|
|
|
listen vip2
|
|
log global
|
|
option httplog
|
|
bind :8002
|
|
mode http
|
|
maxconn 100
|
|
balance url_param foo check_post
|
|
server srv1 127.0.0.1:80
|
|
server srv2 127.0.0.1:80
|
|
hash-preserve-affinity always
|
|
|
|
listen vip3
|
|
log global
|
|
option httplog
|
|
bind :8003
|
|
mode http
|
|
maxconn 100
|
|
balance url_param foo check_post
|
|
server srv1 127.0.0.1:80
|
|
server srv2 127.0.0.1:80
|
|
hash-preserve-affinity maxconn
|
|
|
|
listen vip4
|
|
log global
|
|
option httplog
|
|
bind :8004
|
|
mode http
|
|
maxconn 100
|
|
balance url_param foo check_post
|
|
server srv1 127.0.0.1:80
|
|
server srv2 127.0.0.1:80
|
|
hash-preserve-affinity maxqueue
|