Author:gaojinbo
Time:2011-11-30
linux内核优化配置,减少TIME_WAIT非常有效,希望对大家有帮助。
vi /etc/sysctl.conf
#change for hugwww net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_tw_recycle = 1 net.core.rmem_max = 16777216 net.core.rmem_default = 16777216 net.core.netdev_max_backlog = 262144 net.core.somaxconn = 262144 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_max_orphans = 262144 net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_max_tw_buckets = 15000 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 2 fs.file-max =165535 net.ipv4.ip_local_port_range = 1024 65535 net.ipv4.netfilter.ip_conntrack_max = 1048576 kernel.panic = 5
说明:
net.ipv4.tcp_max_tw_buckets = 15000表示系统同时保持TIME_WAIT套接字的最大数量,如果超过这个数字,TIME_WAIT套接字将立刻被清除并打印警告信息。默认为180000,改为5000。 对于Apache、Nginx等服务器,上几行的参数可以很好地减少TIME_WAIT套接字数量。此项参数可以控制TIME_WAIT套接字的最大数量,避免服务器被大量的TIME_WAIT套接字拖死。
完成!