The TCP KeepAlive (socket option
SO_KEEPALIVE) is governed by three options—time after which the mechanism triggers, probing interval, and number of failed probes after which the connecting is declared broken.
Their defaults are:
- tcp_keepalive_time = 7200
- tcp_keepalive_intvl = 75
- tcp_keepalive_probes = 9
Sending probes after 1¼ minutes sound reasonable, and declaring failure after 9 failed probes does as well, but what is the idea behind the initial time being 2 hours?
Even tcp(7) says
Note that underlying connection tracking mechanisms and application timeouts may be much shorter.
The main point of enabling keepalive is to prevent any stateful network elements from dropping the state information, but such elements tend to drop the connections in a couple of minutes. With some rate-limited servers,
curl with short
--keepalive-time seems to significantly improve reliability of downloads.
So why is the default so long?