Is Redis failover with no downtime possible ?

690 views
Skip to first unread message

rdp

unread,
Aug 2, 2017, 8:37:55 AM8/2/17
to Redis DB
Hi

I am new to Redis , I am trying to use it for websession replication with tomcat server by storing tomcat session in redis.

My setup looks like as follows

1) master  with sentinel
2) slave1 with sentinel
3) slave2 with sentinel


A normal transaction works fine . But when I trigger a failover my killing master process id. 

Failover process starts and while failover is in progress I submit a transaction but as master is unavailable it fails.

I dont want any downtime whn failover is in progress .

Is it possible to achieve this ?

I set sentinel down-after-milliseconds to 5000

How low i can set down-after-milliseconds in order to trigger a quick failover

I am using Redis Session Manager in tomcat context xml.

<Valve
className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager 
                className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
maxInactiveInterval="60" sentinelMaster="mymaster"

Regards,

AlexanderB

unread,
Aug 3, 2017, 6:47:57 PM8/3/17
to Redis DB
Using a smaller number for down-after-milliseconds should help improve the failover time, but the smaller it is, the more likely to trigger false positives. What might happen is that the sentinels think the master has gone down, when in reality, the network between the sentinels and the master is just having a momentary blip. The right setting depends on your setup. If you're running everything on a solid dedicated lan network in a datacenter you can likely tune it quite a bit lower, while if you're on a public cloud, or otherwise on a noisy network keeping closer to this default might be needed to prevent the false positives. 

Since you'll never be able to get it down to an instantaneous failover though you might want to explore doing automatic retries on the client. What you'd want to do is figure out how long the window for failover takes after you've tuned  down-after-milliseconds for your network. Once you've got some rough bounds on how long you expect failover to take, you could add logic to the client to automatically retry on failure for a window of time slightly longer than you're usual failover time. 

If the code that talks to redis is all deep within the RedisSessionManager, you might need to do some digging in there to find out how to get any form of automatic retries working. 
Reply all
Reply to author
Forward
0 new messages