Databases 9 min read

Understanding Redis Cluster Hash Slots: Concepts, Calculation, Allocation, and Dynamic Scaling

This article explains Redis cluster hash slots, how they partition data across 16,384 slots, the CRC16-based slot calculation, slot allocation to nodes, and demonstrates dynamic scaling operations such as adding, reshaping, and removing nodes with practical command‑line examples.

Full-Stack Internet Architecture
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Understanding Redis Cluster Hash Slots: Concepts, Calculation, Allocation, and Dynamic Scaling

Redis cluster uses 16,384 hash slots to shard data across nodes, ensuring even distribution and supporting dynamic scaling.

Each key's CRC16 hash modulo 16,384 determines its slot; slots are assigned to nodes, each node managing a specific range.

Hash slots enable data partitioning, dynamic expansion/reduction, fault tolerance, and easier management.

Example allocation: Node A slots 0‑5500, Node B slots 5501‑11000, Node C slots 11001‑16383.

Commands to view slots, set keys, and observe redirection:

127.0.0.1:7001> set hello world
-> Redirected to slot [866] located at 127.0.0.1:7000
OK

Dynamic scaling: add a new node (port 7006) with

redis-cli --cluster add-node 127.0.0.1:7006 127.0.0.1:7000 -a 123456

, then reshard slots using redis-cli --cluster reshard 127.0.0.1:7000 -a 123456 (move 300 slots to node 7006).

After resharding, verify slot distribution with cluster nodes. To shrink, move slots back and delete the node with

redis-cli --cluster del-node 127.0.0.1:7006 624060ec59626a594ecffdb2f98e7d11a969d78d -a 123456

.

The article concludes that mastering hash slots is essential for Redis cluster operation and interview preparation.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

redisdata shardingClusterDynamic ScalingRedis CLIHash Slots
Full-Stack Internet Architecture
Written by

Full-Stack Internet Architecture

Introducing full-stack Internet architecture technologies centered on Java

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.