在http模式下,无法超过〜11K每秒的Haproxy请求

我没有设法获得每haproxy实例每秒11K的请求。

我在亚马逊EC2上有两个haproxy实例。 在c4.xlarge实例下。 我试图configurationmaxconn参数,CPU映射和linux限制没有任何运气。

我使用Jmeter进行testing,如果我运行两个并行Jmeterconfiguration攻击haproxy每个我mannage得到约22K,但如果我执行相同的configuration,但都只攻击1 haproxy实例最大吞吐量是11K 。

我的haproxyconfiguration是:

global nbproc 4 cpu-map 1 0 cpu-map 2 1 cpu-map 3 2 cpu-map 4 3 maxconn 150000 log /dev/log local0 log /dev/log local1 notice chroot /var/lib/haproxy stats socket /run/haproxy/admin.sock mode 660 level admin stats timeout 30s user haproxy group haproxy daemon # Default SSL material locations ca-base /etc/ssl/certs crt-base /etc/ssl/private # Default ciphers to use on SSL-enabled listening sockets. # For more information, see ciphers(1SSL). This list is from: # https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/ # An alternative list with additional directives can be obtained from # https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS ssl-default-bind-options no-sslv3 defaults log global mode http option httplog option dontlognull option http-server-close retries 2 timeout http-request 10s timeout queue 1m timeout connect 5s timeout client 1m timeout server 1m timeout http-keep-alive 20s timeout check 15s errorfile 400 /etc/haproxy/errors/400.http errorfile 403 /etc/haproxy/errors/403.http errorfile 408 /etc/haproxy/errors/408.http errorfile 500 /etc/haproxy/errors/500.http errorfile 502 /etc/haproxy/errors/502.http errorfile 503 /etc/haproxy/errors/503.http errorfile 504 /etc/haproxy/errors/504.http frontend DSP_FRONT bind *:80 maxconn 300000 default_backend DSP_BACK backend DSP_BACK balance hdr(device) mode http server dsp1 172.31.3.141:80 check server dsp2 172.31.8.195:80 check server dsp3 172.31.8.186:80 check listen stats bind :9000 mode http stats enable stats hide-version stats realm HAproxy-Statistics stats uri /haproxy_stats 

后端应该非常快,响应时间很短(0.5-1kb)。

此外,我试图弄乱系统的限制。

 fs.file-max = 10000000 fs.nr_open = 10000000 net.ipv4.tcp_mem = 786432 1697152 1945728 net.ipv4.tcp_rmem = 4096 4096 16777216 net.ipv4.tcp_wmem = 4096 4096 16777216 net.ipv4.ip_local_port_range = 1000 65535 

并将文件限制添加到haproxy systemd服务中

LimitNOFILE = 300000

但似乎没有改变。

我在ubuntu 16.04下运行haproxy

LE:

cat / proc / [haproxyprocid] /限制的输出

 ubuntu@ip-172-31-1-115:~$ ps ax| grep ha 1214 ? Ss 0:00 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid 1217 ? S 0:00 /usr/sbin/haproxy-master 1218 ? Ss 0:00 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds 1219 ? Ss 0:00 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds 1220 ? Ss 0:00 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds 1221 ? Ss 0:00 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds 1393 pts/0 S+ 0:00 grep --color=auto ha ubuntu@ip-172-31-1-115:~$ cat /proc/1217/limits Limit Soft Limit Hard Limit Units Max cpu time unlimited unlimited seconds Max file size unlimited unlimited bytes Max data size unlimited unlimited bytes Max stack size 8388608 unlimited bytes Max core file size 0 unlimited bytes Max resident set unlimited unlimited bytes Max processes 29852 29852 processes Max open files 300035 300035 files Max locked memory 65536 65536 bytes Max address space unlimited unlimited bytes Max file locks unlimited unlimited locks Max pending signals 29852 29852 signals Max msgqueue size 819200 819200 bytes Max nice priority 0 0 Max realtime priority 0 0 Max realtime timeout unlimited unlimited us 

你没有提到什么是限制因素。 首先你在共享虚拟机上运行,​​所以只有托pipe服务提供者知道他们是否提供了真正的CPU。 其次,如果您强调SSL,可能会使CPU达到最大化。 11k请求/秒可以或多或less地匹配在中等机器上从恢复的TLS连接期望得到的结果。 在这种情况下,您将看到haproxy使用100%的CPU,主要是在用户空间(通常为60%用户/ 40%系统)。 如果你正在做11k RSA2048,那么恭喜你! 如果你是通过清晰的连接来完成的话,那么这个数据很低,但完全可能是由VM环境造成的。 如果它处于保持活动状态的连接上,那么它确实太低了,甚至可能是由于networking延迟很大(对于超量预订的虚拟机也很常见)。