我在 Ubuntu 14.04(修改)上运行了 HAProxy 1.5。它接受 http 和 https 端口上的连接。两个后端应用程序使用持久连接处理请求。
当我创建大约 2200 个客户端连接时,haproxy 停止接受其他连接。但我希望这个系统能够接受至少 10K 的同时连接。
这是连接统计信息:
# 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