linux内存使用率gb,linux – 使用10GB内存的Haproxy和50k连接的100%CPU

在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

人们注意到内存使用量大约在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.

sysctl.conf的

net.core.wmem_max=12582912

net.core.rmem_max=12582912

net.ipv4.tcp_rmem= 10240 87380 12582912

net.ipv4.tcp_wmem= 10240 87380 12582912

haproxy.conf

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

更新

重新启动(不重新加载)haproxy将cpu负载降低到30%.什么可能导致之前的高cpu负载?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值