linux内核参数处理time_wait

linux内核参数处理time_wait
TCP statemeaningis a web server thread utilized?
LISTENno connectionno
SYN_RCVDnot ready to be processedno
ESTABLISHEDready for web server to accept and process requests, or already processing requestsyes, as soon as the web server realizes that connection is established; but if there aren't enough configured web server threads (e.g., MaxClients is too small), the connection may stall until a thread becomes ready
FIN_WAIT1web server has closed the socket; the connection remains in this state until an ACK is received from the client.A web server thread can be utilized for up to two seconds in this state if FIN is not received from the client, after which the web server gives up and the web server thread is no longer utilized.
CLOSE_WAITclient has closed the socket, web server hasn't yet noticedyes
LAST_ACKclient closed socket then web server closed socketno
FIN_WAIT2web server closed the socket then client ACKed; the connection remains in this state until a FIN is received from the client or an OS-specific timeout occurs; see Connections in the FIN_WAIT_2 state and Apache for more informationA web server thread can be utilized for up to two seconds in this state if FIN is not received from the client, after which the web server gives up and the web server thread is no longer utilized.
TIME_WAITwaiting for 2*MSL timeout before allowing quad to be reusedno
CLOSINGweb server and client closed at the same timeno

/etc/sysctl.conf

/usr/lib/sysctl.d/00-system.conf


#对于一个新建连接,内核要发送多少个 SYN 连接请求才决定放弃,不应该大于255,默认值是5,对应于180秒左右时间   

net.ipv4.tcp_syn_retries=2 

net.ipv4.tcp_synack_retries=2 


#当keepalive起用时,TCP发送keepalive消息的频度。缺省是2小时,改为20分钟  

net.ipv4.tcp_keepalive_time=1200  

#减少超时前的探测次数   

 

net.ipv4.tcp_keepalive_probes=5   

net.ipv4.tcp_orphan_retries=3 


#如果套接字由本端要求关闭,这个参数决定了它保持在FIN-WAIT-2状态的时间  

net.ipv4.tcp_fin_timeout=30


#表示SYN队列的长度,默认为1024,加大队列长度为8192,可以容纳更多等待连接的网络连接数。  

net.ipv4.tcp_max_syn_backlog = 4096


#表示开启SYN Cookies。当出现SYN等待队列溢出时,启用cookies来处理,可防范少量SYN攻击,默认为0,表示关闭  

net.ipv4.tcp_syncookies = 1  

  

#表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭  

net.ipv4.tcp_tw_reuse = 1

#表示开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭  

net.ipv4.tcp_tw_recycle = 1  


#优化网络设备接收队列   

net.core.netdev_max_backlog=3000 

转载于:https://www.cnblogs.com/lixuebin/p/10814105.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值