Redis sentinel vs clustering

前端 未结 7 1830
渐次进展
渐次进展 2021-01-29 18:12

I understand redis sentinel is a way of configuring HA (high availability) among multiple redis instances. As I see, there is one redis instance actively serving the client requ

7条回答
  •  伪装坚强ぢ
    2021-01-29 18:14

    Additional info to above answers

    Redis Cluster

    • One main purpose of the Redis cluster is to equally/uniformly distribute your data load by sharding

    • Redis Cluster does not use consistent hashing, but a different form of sharding where every key is conceptually part of what is called as hash slot

    • There are 16384 hash slots in Redis Cluster, Every node in a Redis Cluster is responsible for a subset of the hash slots, so, for example, you may have a cluster with 3 nodes, where:

      Node A contains hash slots from 0 to 5500, Node B contains hash slots from 5501 to 11000, Node C contains hash slots from 11001 to 16383

    This allows us to add and remove nodes in the cluster easily. For example, if we want to add a new node D, we need to move some hash slot from nodes A, B, C to D

    • Redis cluster supports the master-slave structure, you can create slaves A1,B1, C2 along with master A, B, C when creating a cluster, so when master B goes down slave B1 gets promoted as master

    You don't need additional failover handling when using Redis Cluster and you should definitely not point Sentinel instances at any of the Cluster nodes.

    So in practical terms, what do you get with Redis Cluster?

    1.The ability to automatically split your dataset among multiple nodes.

    2.The ability to continue operations when a subset of the nodes are experiencing failures or are unable to communicate with the rest of the cluster.

    Redis Sentinel

    • Redis supports multiple slaves replicating data from a master node.
    • This provides a backup for data in master node.
    • Redis Sentinel is a system designed to manage master and slave. It runs as separate program. The minimum number of sentinels required in an ideal system is 3. They communicate among themselves and make sure that the Master is alive, if not alive they will promote one of the slaves as master, so later when the dead node spins up it will be acting as a slave for the new master
    • Quorum is configurable. Basically it is the number of sentinels that need to agree as the master is down. N/2 +1 should agree. N is the number of nodes in the Pod (note this setup is called a pod and is not a cluster)

    So in practical terms, what do you get with Redis Sentinel?

    It will make sure that Master is always available (if master goes down, the slave will be promoted as master)

    Reference :

    https://fnordig.de/2015/06/01/redis-sentinel-and-redis-cluster/

    https://redis.io/topics/cluster-tutorial

提交回复
热议问题