You may want to enable this for long-lived quiet connections (such as Sentinel connections that can hang around for months) that you want to ensure remain connected. Such as a PUBSUB, where Redis application PING commands aren't necessarily available.
Intermediate routers or NAT devices (eg, in an AWS VPC) may silently drop these long-lived connections after a period of time, and RedisHappy will just never notice. Potentially missing +switch-master events. The SYN/ACK mechanism will attempt to keep these connections alive, and also a provide a way for detecting a problem.
This is very much a last-chance ability to catch a connection failure. The OS will eventually drop the connection, and will (eventually) bubble up as a TCP connection failure that we can deal with, and perhaps try reconnecting/re-syncing.
Example error on the PUB/SUB connection after KeepAlive has decided that the connection is dead:
Coverage remained the same at 74.751% when pulling c5bfd0cac438e0dce098d4d6390a4ac0c8bd1951 on vend:vend_redis_tcp_keepalive into b292e7e6b630bd7ad06e227111448222389d4157 on mdevilliers:master.
Requires the latest
libredis
dependancy, that supports the keepalive options, which has now been merged :) https://github.com/therealbill/libredis/pull/9You may want to enable this for long-lived quiet connections (such as Sentinel connections that can hang around for months) that you want to ensure remain connected. Such as a PUBSUB, where Redis application
PING
commands aren't necessarily available.Intermediate routers or NAT devices (eg, in an AWS VPC) may silently drop these long-lived connections after a period of time, and RedisHappy will just never notice. Potentially missing
+switch-master
events. The SYN/ACK mechanism will attempt to keep these connections alive, and also a provide a way for detecting a problem.This is very much a last-chance ability to catch a connection failure. The OS will eventually drop the connection, and will (eventually) bubble up as a TCP connection failure that we can deal with, and perhaps try reconnecting/re-syncing.
Example error on the PUB/SUB connection after KeepAlive has decided that the connection is dead: