我一直使用HAProxy来平衡我的appservers几个月没有问题。 最近一些stream量峰值导致我设置maxconn参数来限制连接到我的后端服务器。
它工作了好几个小时,然后似乎停止接受任何连接。
我看过我的系统资源图,loadavg和RAM的使用似乎都在控制之下,在冻结之前没有大的峰值。 编辑:Loadavg似乎从冻结前大约从0.13到1.0秒。 这个系统有4个内核,我只是将HAProxy作为一个进程运行 – 当我在冻结之后在htop中查看它时,CPU被locking在100%。
# HA-Proxy version 1.4.16 2011/08/04 global log 127.0.0.1 local0 log 127.0.0.1 local1 notice #log 127.0.0.1 local1 debug #log loghost local0 info maxconn 4096 #chroot /usr/share/haproxy user haproxy group haproxy daemon #debug #quiet defaults log global mode http option httplog option dontlognull retries 3 option forwardfor option redispatch maxconn 2000 contimeout 5000 clitimeout 50000 srvtimeout 50000 listen platform-cache 0.0.0.0:80 mode http maxconn 10000 option abortonclose #balance uri hash-type consistent balance hdr(Host) server varnish1 10.176.129.245 weight 20 maxconn 64 check server varnish2 10.176.129.29 weight 40 maxconn 64 check contimeout 60000 # HTTP response : 'HTTP/1.0 200 OK' listen http_health_check 0.0.0.0:60001 mode health option httpchk listen stats_for_scout 127.0.0.1:8081 mode http stats uri /stats listen public_stats :8080 mode http stats uri /stats stats realm Haproxy\ Statistics stats auth ****************
这里是从一个重新启动到下一个冻结的日志,并重新启动几个小时。
Feb 5 08:57:15 localhost haproxy[31950]: Proxy platform-cache started. Feb 5 08:57:15 localhost haproxy[31950]: Proxy http_health_check started.Feb 5 08:57:15 localhost haproxy[31950]: Proxy stats_for_scout started. Feb 5 08:57:15 localhost haproxy[31950]: Proxy public_stats started. Feb 5 09:43:47 localhost haproxy[31951]: Pausing proxy platform-cache. Feb 5 09:43:47 localhost haproxy[31951]: Pausing proxy http_health_check. Feb 5 09:43:47 localhost haproxy[31951]: Pausing proxy stats_for_scout. Feb 5 09:43:47 localhost haproxy[31951]: Pausing proxy public_stats. Feb 5 09:43:47 localhost haproxy[32746]: Proxy platform-cache started. Feb 5 09:43:47 localhost haproxy[32746]: Proxy http_health_check started. Feb 5 09:43:47 localhost haproxy[32746]: Proxy stats_for_scout started. Feb 5 09:43:47 localhost haproxy[32746]: Proxy public_stats started. Feb 5 09:43:47 localhost haproxy[31951]: Stopping proxy platform-cache in 0 ms. Feb 5 09:43:47 localhost haproxy[31951]: Stopping proxy http_health_check in 0 ms. Feb 5 09:43:47 localhost haproxy[31951]: Stopping proxy stats_for_scout in 0 ms. Feb 5 09:43:47 localhost haproxy[31951]: Stopping proxy public_stats in 0 ms. Feb 5 09:43:47 localhost haproxy[31951]: Proxy platform-cache stopped (FE: 32540 conns, BE: 30334 conns). Feb 5 09:43:47 localhost haproxy[31951]: Proxy http_health_check stopped (FE: 0 conns, BE: 0 conns). Feb 5 09:43:47 localhost haproxy[31951]: Proxy stats_for_scout stopped (FE: 16 conns, BE: 0 conns). Feb 5 09:43:47 localhost haproxy[31951]: Proxy public_stats stopped (FE: 4 conns, BE: 2 conns). Feb 5 17:52:27 localhost haproxy[26610]: Proxy platform-cache started. Feb 5 17:52:27 localhost haproxy[26610]: Proxy http_health_check started. Feb 5 17:52:27 localhost haproxy[26610]: Proxy stats_for_scout started. Feb 5 17:52:27 localhost haproxy[26610]: Proxy public_stats started. ~
原来的configuration已经完美运行了一年多
global log 127.0.0.1 local0 log 127.0.0.1 local1 notice #log 127.0.0.1 local1 debug #log loghost local0 info maxconn 4096 #chroot /usr/share/haproxy user haproxy group haproxy daemon #debug #quiet defaults log global mode http option httplog option dontlognull retries 3 option forwardfor option redispatch maxconn 2000 contimeout 5000 clitimeout 50000 srvtimeout 50000 listen platform-cache 0.0.0.0:80 mode http #balance uri hash-type consistent balance hdr(Host) server varnish1 10.176.129.245 weight 20 check server varnish2 10.176.129.29 weight 40 check # HTTP response : 'HTTP/1.0 200 OK' listen http_health_check 0.0.0.0:60001 mode health option httpchk listen stats_for_scout 127.0.0.1:8081 mode http stats uri /stats listen public_stats :8080 mode http stats uri /stats stats realm Haproxy\ Statistics stats auth *******
谢谢你的帮助!
我碰到了我认为是同样的问题或类似的问题。 我正在运行haproxy,并突然停止接受新的连接。 我尝试将最大连接数从32k增加到65k,当我重新启动时,它看起来更好,但是在haproxy.cfg文件的最大连接限制之前,将停止接受新的连接方式。 我可以看到haproxy统计网页中的更改生效。
然后,我看着/ proc /限制,看到这个:…最大打开文件4026 4026文件…
然后我检查了/ proc // fd,看到当haproxy停止时,我已经打开了大量的文件。 所以我认为问题是底层的unix限制不haproxy。 我增加了过程限制,到目前为止在我的testing中看起来更好。
如果您的问题是由相同的潜在问题引起的,我希望这会有所帮助。
如果您正在configuration的限制,这应该是正常的。 您可以从haproxy 文档中阅读:
maxconn <number> Sets the maximum per-process number of concurrent connections to <number>. It is equivalent to the command-line argument "-n". Proxies will stop accepting connections when this limit is reached.