tcp keepalive 概念

[官方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自帶的保活機(jī)制是 每tcp_keepalive_time 發(fā)一次keepalive包,如果失敗,就會(huì)隔tcp_keepalive_intvl 嘗試發(fā)包tcp_keepalive_probes ,都沒(méi)有收到就認(rèn)為是斷掉了,這個(gè)特性默認(rèn)是關(guān)閉了,要在應(yīng)用層開(kāi)啟。

基于tcp的長(zhǎng)連接一般通過(guò)兩種方式,
1.應(yīng)用層自己實(shí)現(xiàn)ping 協(xié)議?;?br> 2.使用tcp自帶的keepalive ?;?br> 這個(gè)問(wèn)題主要來(lái)源于 connection reset by peer 參考了[https://blog.frognew.com/2018/12/kubernetes-ipvs-long-connection-optimize.html]
但是最后還是沒(méi)有生效,我也不知道哪里的操作方式不對(duì),主要對(duì)k8s 的轉(zhuǎn)發(fā)以及容器本身不了解,也做了很多嘗試

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容