The TCP keepalive option has been incorrectly understood,
Assume that after so_keepalive and related parameters are set through the setsockopt function, the socket uses the configured keepalive related parameters.
Otherwise, use the default keepalive configuration (as follows)
[Email protected]:/# sysctl-A | grep keep
Net. ipv4.tcp _ keepalive_intvl = 30
Net. ipv4.tcp _ keepalive_probes = 9
Net. ipv4.tcp _ keepalive_time = 90
Today, I suddenly found that there are a lot of dead connections on the redis server (many of them were connections a few months ago). I checked the configuration and didn't set the keepalive option. The default value is, 9, 75)
After Google queries that the keepalive option is enabled, the system only configures the value after keepalive is enabled by default;
"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 usingSetsockoptInterface. 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 ."
See: http://tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/ for details