mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-21 20:00:17 +00:00
51406233bb
The new "leastconn" LB algorithm selects the server which has the least established or pending connections. The weights are considered, so that a server with a weight of 20 will get twice as many connections as the server with a weight of 10. The algorithm respects the minconn/maxconn settings, as well as the slowstart since it is a dynamic algorithm. It also correctly supports backup servers (one and all). It is generally suited for protocols with long sessions (such as remote terminals and databases), as it will ensure that upon restart, a server with no connection will take all new ones until its load is balanced with others. A test configuration has been added in order to ease regression testing.
62 lines
2.0 KiB
INI
62 lines
2.0 KiB
INI
# This is a test configuration.
|
|
# It makes use of a farm built from 4 active servers and 4 backup servers,
|
|
# all listenening to different IP addresses on port 80. Health-checks are
|
|
# TCP only on port 81 so that iptables rules permit easy selection of which
|
|
# servers are enabled or disabled.
|
|
#
|
|
# Create statistics counters this way :
|
|
#
|
|
# iptables -N http
|
|
# iptables -A OUTPUT -p tcp --syn --dport 80 -j http
|
|
# for i in $(seq 1 8); do iptables -A http -d 127.0.0.$i; done
|
|
# iptables -A http -d 127.0.0.0/24
|
|
#
|
|
# Consult the statistics using iptables this way:
|
|
#
|
|
# iptables --line-numbers -nxvL http
|
|
# iptables -Z http
|
|
#
|
|
#
|
|
# Block individual servers like this :
|
|
# iptables -I INPUT -p tcp --dport 81 -d 127.0.0.1 -j DROP
|
|
#
|
|
|
|
global
|
|
maxconn 1000
|
|
stats socket /tmp/sock1 mode 600
|
|
stats timeout 3000
|
|
stats maxconn 2000
|
|
|
|
listen sample1
|
|
mode tcp
|
|
retries 1
|
|
redispatch
|
|
contimeout 1000
|
|
clitimeout 120000
|
|
srvtimeout 120000
|
|
maxconn 40000
|
|
bind :8080
|
|
balance leastconn
|
|
option allbackups
|
|
server act1 127.0.0.1:80 weight 10 maxconn 200 check inter 1000 fall 1
|
|
server act2 127.0.0.2:80 weight 20 maxconn 200 check inter 1000 fall 1
|
|
server act3 127.0.0.3:80 weight 30 maxconn 200 check inter 1000 fall 1
|
|
server act4 127.0.0.4:80 weight 40 maxconn 200 check inter 1000 fall 1
|
|
server bck1 127.0.0.5:80 weight 10 check inter 1000 fall 1 backup
|
|
server bck2 127.0.0.6:80 weight 20 check inter 1000 fall 1 backup
|
|
server bck3 127.0.0.7:80 weight 30 check inter 1000 fall 1 backup
|
|
server bck4 127.0.0.8:80 weight 40 check inter 1000 fall 1 backup
|
|
option httpclose
|
|
|
|
listen sample1
|
|
mode http
|
|
contimeout 1000
|
|
clitimeout 50000
|
|
srvtimeout 50000
|
|
maxconn 40000
|
|
bind :8081
|
|
balance leastconn
|
|
option httpclose
|
|
stats uri /stats
|
|
stats refresh 5
|