在我们的测试环境中,我们发现了一个奇怪的HAProxy行为。我们正在使用标准的RHEL 7提供的haproxy-1.5.18-8.el7.x86_64 RPM。
根据我们的理解,可接受的并行连接的总数被定义为来自maxconn*nbproc的global部分的haproxy.cfg。
然而,如果我们定义:
maxconn 5
nbproc 2我们预计并行连接的总数为10,但我们无法超过maxconn定义的5。
为什么nbproc被忽略了?
以下是完整的haproxy.cfg:
# Global settings
global
log 127.0.0.1 local2 warning
log 10.229.253.86 local2 warning
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 5
user haproxy
group haproxy
daemon
nbproc 2
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
stats socket /var/run/haproxy.sock mode 600 level admin
stats socket /var/run/haproxy_hamonit.sock uid 2033 gid 2033 mode 600 level admin
stats timeout 2m
defaults
mode tcp
log global
option tcplog
option dontlognull
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 30s
timeout server 30s
timeout http-keep-alive 10s
timeout check 10s
bind-process all
frontend ha01
bind 10.229.253.89:80
mode http
option httplog
option http-server-close
option forwardfor except 127.0.0.0/8
default_backend ha01
backend ha01
balance roundrobin
mode http
option httplog
option http-server-close
option forwardfor except 127.0.0.0/8
server server1 10.230.11.252:4240 check
server server2 10.230.11.252:4242 check
listen stats 10.229.253.89:1936
mode http
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /
stats auth admin:foo发布于 2019-06-04 13:19:47
我找到罪魁祸首了。我们正在从套接字接口读取统计数据。然而,在我们的配置中,只有一个套接字接口绑定到一个进程。因此,我们无法从其他过程中获得统计数据。不幸的是,HAProxy不支持通过套接字接口进行聚合统计(如果支持,请分享方法)。
所以当我更改为精确绑定时:
stats socket /var/run/haproxy.sock mode 600 level admin process 1
stats socket /var/run/haproxy2.sock mode 600 level admin process 2当nbproc=2时,我可以从两个套接字中获得统计信息:
echo "show sess" | socat /var/run/haproxy.sock stdio
echo "show sess" | socat /var/run/haproxy2.sock stdiohttps://unix.stackexchange.com/questions/522591
复制相似问题