Redis / Jedis does not have a single point of failure and automatic failover

In a simple situation with 3 servers with 1 master and 2 subordinates without a splinter. Is there a proven solution with java and Jedis, which does not have a single point of failure, and will automatically work with a single server that will work as a master or slave (automatic transition to another resource). for example, promoting the wizards and restarting after a crash without any lost data.

It seems to me that this should be solved, but I canโ€™t find any code on it that simply describes the high level of possible ways to do this.

Who actually does this and works in production?

+7
source share
2 answers

You can try Redis Sentinel to achieve this:

Redis Sentinel is a system designed to manage Redis instances. It performs the following three tasks:

  • Monitoring Sentinel constantly checks to see if your subordinate and subordinate instances are working as expected.

  • Notice . Sentinel can notify the system administrator or other computer program through the API that something is wrong with one controlled instance of Redis.

  • Automatic transition to another resource . If the wizard does not work as expected, Sentinel can start the transition process to another resource when the slave promotes other additional slaves reconfigured to use the new wizard and applications using the Redis server reported a new address to use when connecting.

... or use an external solution like Zookeeper and Jedis_failover :

JedisPool pool = new JedisPoolBuilder() .withFailoverConfiguration( "localhost:2838", // ZooKeeper cluster URL Arrays.asList( // List of redis servers new HostConfiguration("localhost", 7000), new HostConfiguration("localhost", 7001))) .build(); pool.withJedis(new JedisFunction() { @Override public void execute(final JedisActions jedis) throws Exception { jedis.ping(); } }); 

Watch the presentation of Zookeeper + Redis .

[Update] ... or a pure Java solution with Jedis + Sentinel is to use a wrapper that handles Redis Sentinel events, see SentinelBasedJedisPoolWrapper .

+9
source

Currently, using Jedis 2.4.2 (from git), I have not found a way to complete a failure based only on redis or sentinel. I hope there will be such a way. I think to explore the zookeeper option right now. redis works well in terms of performance and even stability, but is still in beta.

if anyone understands better, let us know.

+1
source

All Articles