美文网首页
tcp keepalive 概念

tcp keepalive 概念

作者: 不要重不要重 | 来源:发表于2019-05-08 20:00 被阅读0次

[官方doc: https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt]

tcp_keepalive_time - INTEGER
    How often TCP sends out keepalive messages when keepalive is enabled.
    Default: 2hours.

tcp_keepalive_probes - INTEGER
    How many keepalive probes TCP sends out, until it decides that the
    connection is broken. Default value: 9.

tcp_keepalive_intvl - INTEGER
    How frequently the probes are send out. Multiplied by
    tcp_keepalive_probes it is time to kill not responding connection,
    after probes started. Default value: 75sec i.e. connection
    will be aborted after ~11 minutes of retries.

tcp自带的保活机制是 每tcp_keepalive_time 发一次keepalive包,如果失败,就会隔tcp_keepalive_intvl 尝试发包tcp_keepalive_probes ,都没有收到就认为是断掉了,这个特性默认是关闭了,要在应用层开启。

基于tcp的长连接一般通过两种方式,
1.应用层自己实现ping 协议保活
2.使用tcp自带的keepalive 保活
这个问题主要来源于 connection reset by peer 参考了[https://blog.frognew.com/2018/12/kubernetes-ipvs-long-connection-optimize.html]
但是最后还是没有生效,我也不知道哪里的操作方式不对,主要对k8s 的转发以及容器本身不了解,也做了很多尝试

相关文章

网友评论

      本文标题:tcp keepalive 概念

      本文链接:https://www.haomeiwen.com/subject/cfmvoqtx.html