Redis ClusterIntermediate
1Question 1 of 1
bashWhat is Redis Cluster and how do Hash Slots distribute keys across nodes?
Explanation & Concept
Redis Cluster provides automatic sharding across multiple Redis nodes without relying on external proxies.
• Key Space: Fixed into **16,384 Hash Slots**. • Routing: The CRC16 checksum of a key modulo 16384 determines its slot: `CRC16(key) % 16384`. • Hash Tags: Wrapping part of a key in `{}` (e.g., `user:{101}:profile`) ensures related keys hash to the exact same slot, enabling multi-key operations.
Code Example
bash
# Without Hash Tag: May land on different nodes (fails multi-key MGET)
# user:101:profile -> Slot 4520
# user:101:orders -> Slot 12901
# With Hash Tag: Both hash on "101" -> guaranteed same slot!
MGET {user:101}:profile {user:101}:ordersHow It Works & Key Takeaways
Hash tags allow complex multi-key transactions and pipelines within a distributed Redis Cluster by guaranteeing co-location on the same physical shard.
Mock Test · 1 Questions · Optional
Ready for Lua Scripting?
Take a quick test to evaluate yourself, or move straight to the next module.
Advanced1 questions