码迷,mamicode.com
首页 > 其他好文 > 详细

tcp keepalive选项

时间:2014-06-25 09:37:09      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:class   http   使用   os   set   html   

之前一直对tcp keepalive选项理解有误,

以为通过setsockopt函数设置SO_KEEPALIVE和相关参数后该socket则使用设置的keepalive相关参数

否则使用系统默认的:keepalive配置(如下)

root@xxx-KVM:/# sysctl -a | grep keep
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_time = 90

今天突然发现redis服务器上存在大量死链接(很多都是几个月前的连接),检查配置,未设置keepalive选项,系统默认(7200,9,75)

经过google查询出keepalive选项开启才行,系统默认的只是keepalive默认开启后配置值;

"Remember that keepalive support, even if configured in the kernel, is not the default behavior in Linux. Programs must request keepalive control for their sockets using the setsockopt interface. There are relatively few programs implementing keepalive, but you can easily add keepalive support for most of them following the instructions explained later in this document."

 

详细介绍请看:http://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/

 

tcp keepalive选项,布布扣,bubuko.com

tcp keepalive选项

标签:class   http   使用   os   set   html   

原文地址:http://www.cnblogs.com/good90/p/3806820.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!