haproxy中服务器的maxconn参数

我在生产中使用HAProxy来平衡查询到一次只能处理1个查询的一系列服务器实例(通过我们自己的决定)。 知道我在haproxy.cfg文件中的后端configuration的服务器定义行中设置了maxconn参数为1,但服务器仍然得到查询,因为我在服务器的日志消息中看到“查询被拒绝,已经处理”以及HAProxy使用502 http状态码logging返回给客户端的查询。

这是HAProxy的configuration:

# this config needs haproxy-1.1.28 or haproxy-1.2.1 global log 127.0.0.1 local6 debug user haproxy group haproxy daemon stats socket /tmp/haproxy defaults log global mode http balance roundrobin option httplog retries 10 option redispatch frontend custom 0.0.0.0:50000 backlog 2000 acl p5queue avg_queue(custombe) gt 200 tcp-request content reject if p5queue default_backend custombe timeout client 15000 backend custombe retries 10 option redispatch timeout queue 600000 timeout connect 1000 timeout server 120000 server custom-server-1 0.0.0.0:50001 weight 1 maxconn 1 check inter 2000 rise 2 fall 1 server custom-server-2 0.0.0.0:50002 weight 1 maxconn 1 check inter 2000 rise 2 fall 1 server custom-server-3 0.0.0.0:50003 weight 1 maxconn 1 check inter 2000 rise 2 fall 1 server custom-server-4 0.0.0.0:50004 weight 1 maxconn 1 check inter 2000 rise 2 fall 1 server custom-server-5 0.0.0.0:50005 weight 1 maxconn 1 check inter 2000 rise 2 fall 1 server custom-server-6 0.0.0.0:50006 weight 1 maxconn 1 check inter 2000 rise 2 fall 1 server custom-server-7 0.0.0.0:50007 weight 1 maxconn 1 check inter 2000 rise 2 fall 1 server custom-server-8 0.0.0.0:50008 weight 1 maxconn 1 check inter 2000 rise 2 fall 1 server custom-server-9 0.0.0.0:50009 weight 1 maxconn 1 check inter 2000 rise 2 fall 1 server custom-server-10 0.0.0.0:50010 weight 1 maxconn 1 check inter 2000 rise 2 fall 1 

有人知道为什么服务器实例在maxconn参数设置为1时得到查询? 我已经阅读了StackOverflow的问题,其中解释了maxconn,以及它在不同部分如何工作 ,这就是为什么我现在问这个问题,它不应该这样工作。

确保没有其他进程与您的服务打开连接。

需要特别注意的是,在haproxy reload期间,有两个haproxy进程将使用您的资源的时间框架,并且每个强制连接限制都是自己的。 在所有队列耗尽前,整理过程不会终止。 因此,新stream程和客户争夺席位的可能性很大。

我能想到的最好的解决方法是

  1. 每个工作进程和每个进程接受两个连接
  2. 在整理过程仍在运行时,请注意不要重新加载haproxy