What is the redis slot?
Slot concept
Redis Cluster has the concept of a 16384-length slot, and their numbers are 0, 1, 2, 3... …16382, 16383. This slot is a virtual slot and does not really exist.
When working normally, each Master node in Redis Cluster will be responsible for a part of the slots. When a certain key is mapped to a slot responsible for a certain Master, then the Master is responsible for providing services for this key. As for which Master node is responsible for which slot, this can be specified by the user or automatically generated during initialization (redis-trib.rb script).
It is worth mentioning here that in Redis Cluster, only the Master has ownership of the slot. If it is a slave of a Master, the slave is only responsible for the use of the slot, but has no ownership.
Recommended: "Redis Video Tutorial"
Redis Cluster Sharding Implementation
General sharding (Sharding) implementation Methods include list, range and hash (or a combination based on the above).
The implementation of Redis is based on hash sharding, specifically virtual slot partitioning.
Virtual slot partition slot (slot): Use a hash function with good dispersion to map all data to a fixed range of integer sets. This integer set is the slot.
Redis Cluster slot: The range of Redis Cluster slot is 0 ~ 16383. Slots are the basic unit of data management and migration within a cluster.
The above is the detailed content of What is redis slot. For more information, please follow other related articles on the PHP Chinese website!