我们正在尝试为来自客户端(而不是浏览网络交易类型的用户)的 get 和 post 请求找到 haproxy 的最佳调整选项。
使用 30k 线程运行 jmeter 测试,其中包括 5 个对服务器的调用、1 个用户注册和一些更新调用。这些通过管道推送 json 数据。
这是我们当前的 haproxy 配置
global
log /dev/log local0 #notice
maxconn 14000
tune.bufsize 128000
user netcom
group netcom
pidfile /tmp/haproxy.pid
daemon
nbproc 7
#debug
#quiet
defaults
log global
mode http
### Options ###
option httplog
#option logasap
option dontlog-normal
#option dontlognull
option redispatch
option httpchk GET /?method=echo HTTP/1.1
option tcp-smart-accept
option tcp-smart-connect
option http-server-close
#option httpclose
#option forceclose
### load balance strategy ###
balance leastconn
#balance roundrobin
### Other ###
retries 5
maxconn 14000
backlog 100000
### Timeouts ###
#timeout client 25s
timeout client 60s
#timeout connect 5s
timeout connect 60s
#timeout server 25s
timeout server 60s
timeout tunnel 3600s
timeout http-keep-alive 1s
#timeout http-request 15s
timeout http-request 60s
#timeout queue 30s
timeout queue 30s
timeout tarpit 60s
listen stats *:1212
stats enable
stats show-node
stats show-desc xxxxProxy
stats realm xxxxProxy\ Statistics
stats auth xxxx:xxxx
stats refresh 5s
stats uri /
frontend http-in
bind *:1111
bind *:2222 ssl crt /home/netcom/nas/haproxy/xxxx.co.pem verify optional
acl user_request url_reg method=user.register
use_backend user_group if user_request
default_backend other_group
backend user_group
server n15 xxxx:8080 maxconn 3500 check port 8097 inter 2000
server n2 xxxx:8080 maxconn 3500 check port 8097 inter 2000
server n9 xxxx:8080 maxconn 3500 check port 8097 inter 2000
server n14 xxxx:8080 maxconn 3500 check port 8097 inter 2000
server n22 xxxx:8080 maxconn 3500 check port 8097 inter 2000
server n24 xxxx:8080 maxconn 3500 check port 8097 inter 2000
server n25 xxxx:8080 maxconn 3500 check port 8097 inter 2000
以及我们在 centOS 6 上的 sysctl
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries = 2
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_tw_recycle = 1
net.core.wmem_max = 12582912
net.core.rmem_max = 12582912
net.ipv4.tcp_rmem = 20480 174760 25165824
net.ipv4.tcp_wmem = 20480 174760 25165824
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_no_metrics_save = 1
net.core.netdev_max_backlog = 10000
# Syn flood
net.ipv4.tcp_max_syn_backlog = 8096
net.core.somaxconn = 8096
任何人都可以从你的头脑中指出任何明显的问题。不幸的是,我没有 haproxy 方面的专业知识,因此向社区寻求帮助。
我还可能需要弄清楚如何找到盒子可以处理的最大连接数,它在 1 gig 网络上,并且所有后端也都在 1 gig 网络上。这是 haproxy 管理员的屏幕截图http://grab.by/r12c http://grab.by/r12c,请注意,我们正在使用多个核心运行它,因此这是一个核心的快照.. 因为据我所知,网络管理员无法显示所有内容.. 知道如何获取 haproxy 从中获得的最大连接数命令行?
无论如何,只是在努力解决这个问题,并希望任何人都可以提供一些提示或指示。
首先,您似乎不应该运行 haproxy 的多个进程。通常您不想这样做,特别是因为您正忙于测试并试图查看 maxconn。在单核上,haproxy 的性能远远优于您所拥有的 maxconn 设置。
我浏览了 Snapt 的 sysctl,你已经了解了大部分;我注意到它还添加了这些——
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
另外,leastconn 不值得,我建议使用 roundrobin。因为你正在处理由许多小请求组成的 HTTP 流量(老实说,我想这取决于)。不过这些都是小事。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)