1

I have a Spring Cloud based application with multiple backend Spring-Boot servers. The servers are all sharing their session with a single Redis server via @EnableRedisHttpSession.

I now have a requirement for failover support of Redis in production, which means I will have to setup a master-slave configuration (I guess...).

How will I configure Http Session replication via Redis to be aware of the two servers? I could not find any documentation on this. Note that I am not using Spring Data Redis here, just the Spring Session support for Redis.

odedia
  • 931
  • 2
  • 11
  • 27

1 Answers1

3

Spring Session Redis uses Spring Data Redis to integrate with Redis and so you can use Redis Sentinel (see http://redis.io/topics/sentinel). To give you the full picture:

Redis allows managed (Redis Sentinel) and unmanaged Master-Slave setups. Unmanaged setups provide no failover whereas Sentinel managed setups failover the master node once it's down. Redis Sentinel monitors all master/slave nodes and once a master is not available, a slave will be promoted to a new master.

You can configure Spring Data Redis for Sentinel usage with following properties:

  • spring.redis.sentinel.master: name of the master node.
  • spring.redis.sentinel.nodes: Comma delimited list of host:port pairs.

or you provide an own RedisConnectionFactory bean. See Spring Data Redis docs for further details.

HTH, Mark

mp911de
  • 17,546
  • 2
  • 55
  • 95
  • Thank you very much, I will look into it. So just to be clear, there are no code changes required? Just update these two properties in aplication.properties or application.yml? – odedia Jan 18 '16 at 08:19
  • Correct, no code change required (Note: Redis Sentinel is supported since Spring Data Redis 1.4+) – mp911de Jan 18 '16 at 09:20
  • I added info to the first question with my issues, would appreciate if you could have a look and perhaps advise on a solution... Thanks! – odedia Feb 28 '16 at 16:51
  • Thanks, I opened the following question: http://stackoverflow.com/questions/35686670/correct-enableredishttpsession-configuration-with-redis-sentinel – odedia Feb 28 '16 at 18:42