TCP 连接数过高?优化 Linux 网络参数

检查连接状态

ss -s
netstat -an | awk '{print $6}' | sort | uniq -c | sort -rn
ss -tan | grep TIME-WAIT | wc -l

优化参数(/etc/sysctl.conf)

net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 1024 65000
net.core.somaxconn = 1024
net.ipv4.tcp_max_syn_backlog = 1024

sysctl -p  # 立即生效

查看文件描述符限制

ulimit -n
cat /etc/security/limits.conf | grep nofile

发表评论

京ICP备2022034122号