Pegasus1985
Pegasus1985

Reputation: 186

Redis advantages of Sentinel and Cluster

I'm planning to create a high available Redis Cluster. After reading many articles about building Redis cluster i'm confused. So what exactly are

Further questions to the Redis Sentinel Master1 Slave1 Slave2 Cluster:

Further questions to the Redis Multinode Sharded Cluster:

I'm unsure if these two solutions are the only ones. Hopefully you guys can help me to understand the architectures of Redis. Sorry for so many questions.

Upvotes: 6

Views: 4601

Answers (1)

Elad Tamary
Elad Tamary

Reputation: 576

I will try to answer some of your questions but first let me describe the different deployment options of Redis. Redis has three basic deployments: single node, sentinel and cluster.

  • Single node - The basic solution where you run single process running Redis. It is not scalable and not highly available.
  • Redis Sentinel - Deployment that consist of multiple nodes where one is elected as master and the rest are slaves. It adds high availability since in case of master failure one of the slaves will be automatically promoted to master. It is not scalable since the master node is the only node that can write data. You can configure the clients to direct read requests to the slaves, which will take some of the load from the master. However, in this case slaves might return stale data since they replicate the master asynchronously.
  • Redis Cluster - Deployment that consist of at least 6 nodes (3 masters and 3 slaves). where data is sharded between the masters. It is highly available since in case of master failure, one of his slaves will automatically be promoted to master. It is scalable since you can add more nodes and reshard the data so that the new nodes will take some of the load.

So to answer your questions:

  1. The advantages of Sentinel over Redis Cluster are:
    • Hardware - You can setup fully working Sentinel deployment with three nodes. Redis Cluster requires at least six nodes.
    • Simplicity - usually it is easier to maintain and configure.
  2. The advantages of Redis Cluster over Sentinel is that it is scalable.

The decision between that two deployment should be based on your expected load. If your write load can be managed with a single Redis master node, you can go with Sentinel deployment.

If one node cannot handle your expected load, you must go with Cluster deployment.

  1. Redis Sentinel deployment is not scalable so making the cluster bigger will not improve your performance. The only exception is that adding slaves can improve your read performance (in case you direct read requests to the slaves).

  2. Redis Cluster running on a single node with multiple ports is only for development and demo purposes. In production it is useless.

  3. In Redis Cluster deployment clients should have network access to all nodes (and node only Master1). This is because data is sharded between the masters. In case client try to write data to Master1 but Master2 is the owner of the data, Master1 will return a MOVE message to the client, guiding it to send the request to Master2. You cannot have a single HAProxy in front of all Redis nodes.

  4. Same answer as in 5, in the cluster deployment clients should have direct connection to all masters and slaves not through LB or Keepalived.

  5. Not sure I totally understood your question but Redis Cluster is the only solution for Redis that is scalable.

  6. Redis Cluster deployment support multikey operations only when all keys are in the same node. You can use "hash tags" to force multiple keys to be handled by the same master.

Some good links that can help you understand it better:

Description on the different Redis deployment options: https://blog.octo.com/en/what-redis-deployment-do-you-need

Detailed explanation on the architecture of Redis Cluster: https://blog.usejournal.com/first-step-to-redis-cluster-7712e1c31847

Upvotes: 16

Related Questions