Connect Redis cluster to jedis

Since one instance of redis does not meet my requirements, I went for redis cluster. I formed a cluster with three nodes and the data entered into the cluster. When I get data from a cluster using JedisCluster, it takes more time than one instance. So how to properly connect jedis with a redis cluster. How can I use the connection pool to connect jedis to a redis cluster?

+4
source share
2 answers

It's normal that you observe latency when retrieving data in a jedis cluster, depending on the clustering strategy you have, because you will receive money from one jedis to another to take data. The red arrow is the reason for adding time to queries in the jedis cluster.

jedis vs jedis cluster

The only way to access the correct instance is to understand by key the location of your data, enter into the key, for example, the location: "instance3 / user / 5" or find an instance of the location that performs calculations on the keys.

+1
source

JedisCluster creates its own pool. You can specify the pool configuration when creating the JedisCluster object. From now on, you can consider the cluster as a separate instance, and the requests will be sent to the corresponding instance of the cluster.

JedisCluster cluster - new JedisCluster(...); ... cluster.set(key, value);

, , getSlot(), , . - .

+1

Source: https://habr.com/ru/post/1599297/


All Articles