我有Ubuntu 14.04(修改)上运行的HAProxy 1.5。 它接受http和https端口上的连接。 两个后端应用程序使用持久连接处理请求。
当我创build大约2200个客户端连接时,haproxy停止接受其他连接。 但是我希望这个系统能够接受至less10K个同时连接。
这里是连接统计:
# ss -s TCP: 4119 (estab 4098, closed 6, orphaned 0, synrecv 0, timewait 6/0), ports 0 Transport Total IP IPv6 TCP 4113 4106 7 INET 4128 4117 11
我已经调整过程的最大打开文件数量:
# cat /proc/1012/limits Limit Soft Limit Hard Limit Units Max open files 240017 240017 files
我的haproxy.config文件:
global log /dev/log syslog debug daemon user haproxy group haproxy maxconn 120000 spread-checks 4 defaults log global timeout connect 30000ms timeout client 300000ms timeout server 300000ms frontend http-in mode http bind :80 option httplog option forwardfor reqadd X-Forwarded-Proto:\ http default_backend http-routers frontend https-in mode http bind :443 ssl crt /opt/haproxy/cert.pem no-sslv3 option httplog option forwardfor option http-server-close reqadd X-Forwarded-Proto:\ https default_backend http-routers frontend ssl-in mode tcp bind :4443 ssl crt /opt/haproxy/cert.pem no-sslv3 default_backend tcp-routers backend http-routers mode http balance roundrobin server node0 192.168.10.2:80 check inter 1000 server node1 192.168.10.2:80 check inter 1000 backend tcp-routers mode tcp balance roundrobin server node0 192.168.10.2:80 check inter 1000 server node1 192.168.10.2:80 check inter 1000
据我所知,监听块maxconn是不同的,然后全球maxconn。 使用全局maxconn,可以限制haproxy进程处理的最大连接数。
监听/前端部分有其自己的maxconn,这限制了每个监听者的连接数量。 所以,试着在你的前端部分设置maxconn,或者至less在默认部分设置它。
所以:
defaults maxconn 10000
或者每个前端进行设置。
HAProxy机器的硬件configuration是什么? 内核,内存,networking接口等?
我们遇到了许多HAProxy性能问题。 这里有一些想法:
将stream量分成两个HAProxy服务器,每个服务器充当另一个的备份。
提高nbproc以反映特定硬件上的内核数量。
如果您正在使用第7层模式,请参阅是否可以下拉到第4层模式以获得更高的吞吐量。