Jedis redis-ha with sentinel questions

106 views
Skip to first unread message

Edi V

unread,
Mar 31, 2020, 6:52:07 PM3/31/20
to Jedis
Hi All,

I am exploring jedis library for our redis cluster setup with Master-Slave-Sentinel deployment. 

I have the following deployment presently -

1]  Bunch of master redis instances
2]  Bunch of slave redis instances (1 slave per master)
3]  Bunch of sentinels monitoring all the Master/Slave instances

I need the following functionality -

1] Client to connect to sentinel for getting the cluster state
2] Client writer to partition data evenly across all masters by key to be flushed to the bunch of masters
3] Client writer should have ability to receive notifications of new masters (which were slaves earlier) when there is a failover of an existing master
4] Client should have the ability to pipeline the requests for better performance
5] The connections to every redis instance should support pooling
6] The ability to scale up and down the number of masters-slave nodes with the client seamlessly able to catch up with the cluster state dynamically 

I would like to know whether Jedis library can support all the 6 points I have listed above.

More specifically I am interested in know the following -

1] At start 
    a) Client queries sentinels to get the list of masters
    b) This list is used to create an in memory state of the cluster by client as follows -

    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    ShardedJedisPool pool = new ShardedJedisPool(jedisPoolConfig, shards);

  c) In case of failover when master fails and slave gets promoted to master how do I update this in memory state in a thread safe
     performant way considering traffic will be flowing through the system as client gets notification from the sentinel about the
     failed and newly elected nodes. Do I need to explicitly do this or will the Jedis client take care of updating the state 
     automatically in a dynamic way.

  d) What happens when the number of nodes increases or decreases. will this cause shifting of all the keys or does the jedis client use
     consistent-hashing which will cause only K/N keys to be shifted.


Regards,
Aditya







    

Allan Wax

unread,
Apr 1, 2020, 2:30:53 PM4/1/20
to Jedis
While thjis answer does not directly answer your question, I would recommend going with another Redis technology rather than the sentinel.. Much easier than setting up sentinels.

I would go straight to Redis Cluster.  It takes care of everything you've mentioned above and is much easier to manage.  Setup is easy with redis-trib and once set up, you can basically forget about it.  The only drawback is that pipelines don't work (you have to lock all the servers for the operation) and multi-key operations all have to reference the same server.  I know there are improvements to Redis coming so things may have changed since I used Redis 4 about 2 years ago.

Again, only a recommendations.

Edi V

unread,
Apr 1, 2020, 3:18:29 PM4/1/20
to Jedis
Thanks Allan for your inputs.

From the perspective of pipelining of cmds is pipelining a feature to be supported by redis server or is it a feature that needs to be supported by the client. I was reading up on another competing client library
called Lettuce and came across the following -


Regards,
Adi

Allan Wax

unread,
Apr 2, 2020, 1:52:56 PM4/2/20
to Jedis
I read the article.  I use Jedis which is the most popular Java interface to Redis.  I can't say that there is no way to do pipelining on a cluster but I can say that in a cluster multikey operations that reference different instances are not allowed (my knowledge is based upon Redis 4.x).  There is a way to do multikey operations on a server guaranteed to work in a cluster.  If you have multiple keys associated with each other, like "company-x-traffic" and "company-x-bandwidth" there is a common part "company-x".  Using what I call shard direction notation "{...}" which guarantees that all keys with the same shard direction part reside on the same server, you can rewrite the keys as "{company-x}-traffic" and "{company-x}-bandwidth".  Those two keys are guaranteed to be on the same server and multikey operation will succeed in a cluster.  This may also allow you to do pipelining with those keys but I haven't tried it.  I think Jedis just won't allow you to create a pipeline on a cluster.  I don't know.

Note that shard notation becomes part of the key.  You always have to refer to that key in that way.  Without the notation, it is a different key.

Hope this helps

Edi V

unread,
Apr 2, 2020, 6:11:01 PM4/2/20
to Jedis

Thanks Allan for your analysis and inputs! That helps. 

Regards,
Adi
Reply all
Reply to author
Forward
0 new messages