Redis - Handling Failover and Load Balancing?
Asked Answered
P

2

7

I have an application that uses Redis Tomcat Session Manager in order to connect to the Redis Server in order to externalize the sessions. Since we are targeting high availability, we wanted to run Redis Master-Slave configuration in a distributed manner. We are successfully able to achieve it in a single server with multiple Master-Slave configuration and we use sentinal to do so.

Our problem starts when we move from a single server to multiple server environment, i.e Consider we have servers s1,s2,s3 and Master runs in s1 whereas s2 and s3 runs slave processes. Sentinal easily does a switch over whenever the s1 master dies but our application is totally unaware of the switch over and keeps on pointing to the IP of s1 server whereas the master now is s2. How to address this problem and how can we increase the availability.

The configuration changes that we do in the Apache Tomcat is in the Server.xml file and is as follows :-

<Valve className="com.radiadesign.catalina.session.RedisSessionHandlerValve" />
<Manager className="com.radiadesign.catalina.session.RedisSessionManager"
         host="localhost" <!-- optional: defaults to "localhost" -->
         port="6379" <!-- optional: defaults to "6379" -->
         database="0" <!-- optional: defaults to "0" -->
         maxInactiveInterval="60" <!-- optional: defaults to "60" (in seconds) --> />

How to get along with this situation and increase the availability. I read some plugins with zookeeper but none for Java and dont even know how would we implement the same.

Please feel free to ask any clarification if required.

Pistoleer answered 13/1, 2014 at 12:58 Comment(3)
I haven't done it myself so I don't know all the gnarly details, but I think people are successfully failing over with twemproxy.Katt
@Katt Ok I see is this proxy able to do switch over without sentinal.Pistoleer
I don't think so. Sorry if it's not clear, but there are two links hidden in my first comment, I'll repeat so that it's more apparent:jambr.co.uk/Article/redis-twemproxy-agent and github.com/twitter/twemproxyKatt
H
1

You'll probably want to have a look at HAProxy. I had a similar situation a few days ago setting up a high availability Redis service in Windows Azure. I documented how to do this here:

http://robertianhawdon.me.uk/2014/02/11/sysops-installing-a-high-availability-redis-service-on-centos-6-x-in-windows-azure/

Cheers

Hildie answered 15/2, 2014 at 16:28 Comment(0)
E
1

Sentinal easily does a switch over whenever the s1 master dies but our application is totally unaware of the switch over and keeps on pointing to the IP of s1 server whereas the master now is s2

Try Redisson it automatically updates Redis topology, in particular handles master change as in your case. It also supports Single/Sentinel/Cluster and AWS Elasticache modes and of course implements Tomcat Session Manager.

Enchanter answered 28/11, 2016 at 11:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.