mdevilliers / redishappy

Redis Sentinel high availabillity daemon
Apache License 2.0
114 stars 23 forks source link

Redis OS TCP Keepalive #41

Closed scottgeary closed 8 years ago

scottgeary commented 8 years ago

Requires the latest libredis dependancy, that supports the keepalive options, which has now been merged :) https://github.com/therealbill/libredis/pull/9

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:

INFO: 2016/03/09 23:24:04 monitor.go:X: Subscription Message :  : Error read tcp 10.10.10.5:26379: connection timed out
coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 74.751% when pulling c5bfd0cac438e0dce098d4d6390a4ac0c8bd1951 on vend:vend_redis_tcp_keepalive into b292e7e6b630bd7ad06e227111448222389d4157 on mdevilliers:master.