Course contentsShow
← Cloud and Infrastructure
Lesson 2688 of 2,98958. Caching StrategiesFree lesson

Redis Cluster for Horizontal Scaling

Implement Redis Cluster to partition data across multiple nodes for scalability.

Redis Cluster for Horizontal Scaling

What you'll learn: How Redis Cluster automatically partitions data across multiple nodes to scale horizontally beyond a single server's capacity.

Why Cluster Beyond Sentinel?

Redis Sentinel handles high availability with replication, but all data still lives on one master node. Redis Cluster solves a different problem: splitting your dataset across multiple masters so you can store more data and handle more throughput than any single machine can support.

How Redis Cluster Works

Redis Cluster uses hash slots to partition data. Redis divides the keyspace into 16,384 slots, and assigns ranges of these slots to different master nodes:

  • Keys are hashed to determine their slot: HASH_SLOT = CRC16(key) mod 16384
  • Node A might own slots 0-5460, Node B slots 5461-10922, Node C slots 10923-16383
  • When a client requests a key, it calculates the slot and connects to the correct node
  • If you connect to the wrong node, Redis redirects you with a MOVED response

Think of it like a library system: instead of one building holding all books, you have three branches, each responsible for certain call number ranges. Patrons learn which branch has their book and go directly there.

Scaling in Action

You start with 3 master nodes. Need more capacity? Add more masters and Redis redistributes slots. Each master can have replicas for fault tolerance (combining Cluster with replication concepts).

Unlike application-level sharding, Redis Cluster handles routing automatically—clients discover the cluster topology and send commands directly to the right node.

Key Takeaway: Redis Cluster partitions data across multiple masters using hash slots, enabling horizontal scaling beyond single-server limits while maintaining automatic routing and built-in shard management.