Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is application level heartbeating preferable to TCP keepalives?

Tags:

sockets

zeromq

Is there a reason why I should use application level heartbeating instead of TCP keepalives to detect stale connections, given that only Windows and Linux machines are involved in our setup?

like image 583
Alex Grönholm Avatar asked Nov 02 '13 12:11

Alex Grönholm


People also ask

Does TCP send keepalive?

The short answer is yes there is a timeout enforced via TCP Keep-Alive, so no the socket won't remain open forever but will probably time out after a few hours.

What is TCP heartbeat?

A heartbeat is a type of a communication packet that is sent between nodes. Heartbeats are used to monitor the health of the nodes, networks and network interfaces, and to prevent cluster partitioning.

What is the default value of the TCP keepalive timer?

The default is 300 seconds. The Keep Alive Interval setting in the TCP profile is used to adjust the frequency at which the BIG-IP system sends TCP Keep-Alive packets to a remote host for connection validation.

What does TCP keepalive do?

The TCP Keepalive Timer feature provides a mechanism to identify dead connections. When a TCP connection on a routing device is idle for too long, the device sends a TCP keepalive packet to the peer with only the Acknowledgment (ACK) flag turned on.


1 Answers

It seems that the TCP keepalive parameters can't be set on a per-socket basis on Windows or OSX, that's why.

Edit: All parameters except the number of keepalive retransmissions can in fact be set on Windows (2000 onwards) too: http://msdn.microsoft.com/en-us/library/windows/desktop/dd877220%28v=vs.85%29.aspx

I was trying to do this with zeromq, but it just seems that zeromq does not support this on Windows?

like image 130
Alex Grönholm Avatar answered Jan 03 '23 10:01

Alex Grönholm