大量长连接服务器配置

以centos6.5为例

1.修改/etc/sysctl.conf,sysctl-p执行

net.netfilter.nf_conntrack_max = 655350
net.core.somaxconn = 2048
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
net.ipv4.tcp_mem = 786432 2097152 3145728
net.ipv4.tcp_max_syn_backlog = 16384
net.core.netdev_max_backlog = 20000
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_orphans = 131072
net.ipv4.tcp_timestamps=0
net.ipv4.tcp_max_tw_buckets=100000

2.修改打开文件句柄数上限:

echo -n 2000000 > /proc/sys/fs/nr_open

3.修改/etc/security/limits.conf,以root用户为例

root               soft     nproc          100000
root               hard     nproc          100000
root               soft     nofile         2000000
root               hard     nofile         2000000

相关推荐