Databases 8 min read

How Redis Cluster Achieves Linear Scalability and High Availability

This article explains how Redis Cluster uses hash slots for data partitioning, enables near‑linear scaling and fault‑tolerant failover through master‑slave replication, and requires client‑side routing support, while discussing the trade‑off between performance and consistency in distributed systems.

ITPUB
ITPUB
ITPUB
How Redis Cluster Achieves Linear Scalability and High Availability

Scalable Design of Redis Cluster

Redis Cluster introduces the concept of hash slots to partition data; the cluster has 16,384 slots, and each node is responsible for a subset of these slots. For example, with three nodes the distribution could be:

Node A: slots 0‑5500

Node B: slots 5501‑11000

Node C: slots 11001‑16383

When a client accesses a key, Redis computes CRC16(key) mod 16384 to determine the slot, then routes the request to the node owning that slot. HASH_SLOT = CRC16(key) mod 16384 The hash‑slot mechanism enables dynamic scaling: adding or removing nodes triggers data migration at the granularity of slots, allowing near‑linear growth of storage and throughput without client disruption.

During migration, if a key’s slot is being moved from node A to node B, the cluster continues to direct requests to node A. If the key has already migrated, node A redirects the client to node B, which then serves the request. New keys for the migrating slot are created directly on the target node.

Redis hash slot distribution
Redis hash slot distribution

High‑Availability Design of Redis Cluster

Redis Cluster achieves high availability through master‑slave replication. Each master node has a replica (e.g., A1 replicates A). If a master fails, its replica is elected as the new master, and the cluster continues serving requests.

Failover steps (simplified):

Master A crashes; the cluster promotes A1 to master.

During the election, some read/write operations may fail.

When the original master restarts, it rejoins as a replica.

Redis favors performance over strong consistency because replication is asynchronous. The write flow is:

Client writes to master B.

Master B returns OK immediately.

Master B asynchronously forwards the write to its replica B1.

If master B crashes before the replica acknowledges the write, the data may be lost after failover, illustrating the classic performance‑vs‑consistency trade‑off.

Redis replication flow
Redis replication flow

Redis Cluster Client Considerations

Clients must be aware of the cluster topology. They need to configure multiple node IPs and cache the mapping between hash slots and nodes, allowing direct routing of commands to the appropriate node and improving performance.

The overall cluster design therefore involves both server‑side mechanisms (hash‑slot partitioning, replication, failover) and client‑side support (slot‑to‑node routing), which together deliver scalable and highly available Redis deployments.

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.

ScalabilityredisCluster
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.