Nyx*_*nyx 6 networking linux ubuntu tcp haproxy
在 Ubuntu 14.04 x64 服务器上,Haproxy 使用 3.3 GB 内存和 6.8 GB 交换,同时处理 52k 连接。在大部分流量被重定向到另一个 haproxy 框之前,CPU 使用率也一直飙升至 100%。流量主要是持久性 TCP 连接。
pid = 3185 (process #1, nbproc = 1)
uptime = 0d 6h14m21s
system limits: memmax = unlimited; ulimit-n = 524341
maxsock = 524341; maxconn = 262144; maxpipes = 0
current conns = 54303; current pipes = 0/0
Running tasks: 1/54336
Run Code Online (Sandbox Code Playgroud)
注意到内存使用量在大约 50k 连接时急剧上升。ulimit -n设置为1048576。
问题:内存使用量是否异常高?我们怎样才能减少内存消耗?
我还从另一个问题中阅读了以下内容,是否相关?我应该如何检查 TCP 设置是否足够(对于持久 TCP 连接),以免导致内存使用量大幅增加?
At 54000 concurrent connections, you should be careful about your TCP settings. If running with default settings (87kB read buffer, 16kB write buffer), you can end up eating 10 gigs of memory just for the sockets.
Run Code Online (Sandbox Code Playgroud)
配置文件
net.core.wmem_max=12582912
net.core.rmem_max=12582912
net.ipv4.tcp_rmem= 10240 87380 12582912
net.ipv4.tcp_wmem= 10240 87380 12582912
Run Code Online (Sandbox Code Playgroud)
配置文件
global
log /dev/log local0
log /dev/log local1 notice
maxconn 262144
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon
defaults
log global
mode tcp
option tcplog
option dontlognull
option redispatch
retries 3
maxconn 262144
contimeout 180000
clitimeout 180000
srvtimeout 180000
timeout contimeout 180000
timeout connect 180000
timeout client 180000
timeout server 180000
Run Code Online (Sandbox Code Playgroud)
重新启动(而不是重新加载)haproxy 将 CPU 负载降低到 30%。什么可能导致以前的高 CPU 负载?
| 归档时间: |
|
| 查看次数: |
5950 次 |
| 最近记录: |