Redis Cluster and Sharding
Learn how Redis Cluster scales a cache horizontally across many nodes using hash slots, how keys are routed, and how to keep related keys together with hash tags.
Why Scale Beyond One Node?
A single Redis instance is limited by one server's memory and throughput. Redis Cluster spreads data across many nodes so the cache can grow far beyond a single machine.
Hash Slots
Redis Cluster divides the keyspace into 16384 hash slots. Each node owns a range of slots. A key belongs to exactly one slot, determined by hashing the key.
TOTAL_SLOTS = 16384
def slot_for(crc):
return crc % TOTAL_SLOTS
print('Slot:', slot_for(123456789))All lessons in this course
- Redis Persistence & HA
- Distributed Caching with Redis
- Redis Pub/Sub for Invalidation
- Redis Cluster and Sharding