[官方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ā)以及容器本身不了解,也做了很多嘗試