我有一个关于我的haproxy配置的问题:
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
log 127.0.0.1 syslog emerg
maxconn 4000
quiet
user haproxy
group haproxy
daemon
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option abortonclose
option dontlognull
option httpclose
option httplog
option forwardfor
option redispatch
timeout connect 10000 # default 10 second time out if a backend is not found
timeout client 300000 # 5 min timeout for client
timeout server 300000 # 5 min timeout for server
stats enable
listen http_proxy localhost:81
balance roundrobin
option httpchk GET /empty.html
server server1 myip:80 maxconn 15 check inter 10000
server server2 myip:80 maxconn 15 check inter 10000
正如您所看到的那样,这很简单,但是我对maxconn属性的工作原理有点困惑。
有全局的和在listen块中的服务器的maxconn,我的想法是:全局的管理haproxy作为服务一次排队或处理的连接总数。如果数字超过了这个数字,它会杀死连接,还是在某些Linux套接字中池化?如果数字超过4000,我不知道会发生什么。
然后你有设置为15的服务器maxconn属性。首先,我将其设置为15,因为我的php-fpm,这是转发到另一台服务器上的,只能使用有限数量的子进程,因此我确保在这里汇集请求,而不是在php-fpm中。我认为这更快。
但是回到主题,我对这个数字的理解是,此块中的每个服务器一次只会发送15个连接。然后连接将等待一个开放的服务器。如果我打开cookie,则连接将等待正确的开放服务器。但我没有。
那么问题是:
- 如果全局连接超过4000会发生什么?他们会死亡吗?还是在Linux上池化?
- 除了不能拥有大于全局连接的总服务器连接数之外,全局连接与服务器连接有关系吗?
- 在计算全局连接时,不应该是在服务器部分中添加的连接总数再加上一定比例的汇集吗?显然,您还有其他连接限制,但实际上是要发送到代理的连接数量吗?
提前谢谢。