[zeromq-dev] Heartbeats and/or keep-alives
Pieter Hintjens
ph at imatix.com
Thu Oct 14 09:45:56 CEST 2010
On Thu, Oct 14, 2010 at 9:02 AM, Martin Sustrik <sustrik at moloch.sk> wrote:
> That would be the best solution, as the only sane place to implement
> keepalives is OSI level 4. However, TCP specs (RFC1122) specify that
> keepalive timeout is at least 2 hours. It's a long-known and widely
> discussed problem with TCP. It have been solved in SCTP, but again, not
> everybody is willing to switch to SCTP, etc.
It's not about TCP vs. SCTP except in one case. The use cases are:
1. to work around TCP's problem of not reporting disconnected peers
2. to distinguish silent applications from dead ones ('heartbeating')
3. to force intermediaries to keep connections open ('keepalive')
You can basically solve all three use cases in one go by sending
heartbeat messages when a connection is otherwise idle, and treating
the lack of incoming heartbeats as a fatal error. We discussed
previously how to do this optimally, by sending heartbeats
progressively more slowly during idle periods. The recipient only
needs to detect "sudden silence", i.e. a sharp drop, meaning something
died.
The most common cause of problems is blocked (looping) applications,
which is why doing this at level 4 is useless. The right place seems
to be the tcp:// transport.
-
Pieter Hintjens
iMatix - www.imatix.com
More information about the zeromq-dev
mailing list