Understanding Redis Cluster: Sharding, High Availability, and Hash Slot Mechanics
This article explains Redis Cluster’s automatic sharding, built‑in high availability, the role of the cluster bus ports, the limitations of traditional hash algorithms, and how consistent hashing with virtual nodes and the 16384‑slot hash slot mechanism enable efficient data distribution and low‑cost node scaling.
1. Redis Cluster Overview
1.1 Automatic data sharding, each master holds a portion of data
1.2 Built‑in high availability; the cluster continues operating when some masters fail
In a Redis Cluster each node opens two ports, e.g., 6379 and 16379 (6379+10000). The second port is used for the cluster bus, which handles node communication, failure detection, configuration updates, and failover authorization.
The cluster bus uses a binary protocol optimized for efficient data exchange, consuming less bandwidth and processing time.
2. The oldest hash algorithm and its drawbacks (massive cache rebuilds)
3. Consistent hashing with virtual nodes for automatic cache migration and load balancing
4. Redis Cluster hash slot algorithm
Redis Cluster defines 16384 hash slots. For each key, CRC16 is computed and modulo 16384 yields the slot.
Each master owns a subset of slots; for example, with three masters each may hold about 5000 slots.
Hash slots simplify node addition and removal: adding a master moves some slots from existing masters; removing a master transfers its slots to others.
The cost of moving hash slots is very low.
Clients can force keys to the same slot using hash tags.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
