What is the difference between Redis replication and Redis Cluster?
Redis replication copies the full dataset to replicas for read scaling, while Redis Cluster shards the keyspace across primaries. See the key differences.
Expected Interview Answer
Redis replication copies the full dataset from one primary to one or more read-only replicas for redundancy and read scaling, while Redis Cluster horizontally partitions the keyspace across many primaries so both data and writes are distributed.
In plain replication every node holds the entire dataset, so it solves availability and read fan-out but not memory or write throughput limits, and failover requires Sentinel or manual promotion. Redis Cluster splits the keyspace into 16384 hash slots spread across multiple primary shards, each with its own replicas, giving automatic failover, distributed writes, and capacity that scales beyond a single machine's RAM at the cost of multi-key operation constraints.
- Replication: simple setup, read scaling, and data redundancy
- Cluster: writes and memory scale horizontally across shards
- Cluster: built-in automatic failover without external Sentinel
- Replication: full dataset on every node keeps queries simple
- Cluster: no single node holds the whole dataset, reducing blast radius
AI Mentor Explanation
Replication is like every scorer in the box keeping an identical full scorebook, so if one book is lost another has all runs; Cluster is like splitting the tournament across venues where each ground records only its own matches and has its own backup scorer.
Step-by-Step Explanation
Step 1
Start with a primary
A single Redis primary holds the full dataset and accepts all writes.
Step 2
Add replicas for replication
Attach read-only replicas that copy the primary via an async replication stream for redundancy and read scaling.
Step 3
Hit the single-node ceiling
When dataset size or write volume exceeds one machine, replication alone can no longer help.
Step 4
Enable Cluster mode
Partition the keyspace into 16384 hash slots and assign ranges to multiple primary shards.
Step 5
Give each shard replicas
Each primary shard gets its own replicas so a shard failure triggers automatic promotion of one of its replicas.
What Interviewer Expects
- Knowing replication scales reads but not writes or memory
- Understanding Cluster partitions the keyspace across primaries
- Awareness of the 16384 hash slot model
- Recognising Cluster's automatic failover versus Sentinel-driven failover
- Mentioning multi-key operation limits inside a cluster
Common Mistakes
- Thinking replicas increase write throughput
- Assuming Redis Cluster keeps a full dataset copy on every node
- Confusing Sentinel (HA for replication) with Cluster (sharding + HA)
- Ignoring cross-slot restrictions on multi-key commands in a cluster
Best Answer (HR Friendly)
“Replication makes complete copies of the same Redis data on backup servers, which is great for reliability and handling more reads. Redis Cluster instead splits the data into pieces spread across many servers, so it can store more and handle more writes than any single machine could.”
Code Example
# On the replica node
redis-cli REPLICAOF 192.168.1.10 6379
# Check the replication link
redis-cli INFO replication
# role:slave master_link_status:upredis-cli --cluster create \
192.168.1.10:6379 192.168.1.11:6379 192.168.1.12:6379 \
192.168.1.13:6379 192.168.1.14:6379 192.168.1.15:6379 \
--cluster-replicas 1
# Inspect slot distribution
redis-cli -c -p 6379 CLUSTER SLOTSFollow-up Questions
- How does Redis handle failover in a plain replication setup?
- Why is the keyspace split into exactly 16384 hash slots?
- What are the limitations on multi-key commands in Redis Cluster?
- How do hash tags force related keys into the same slot?
- When would you choose Sentinel over Cluster?
MCQ Practice
1. What does Redis Cluster distribute across its primary nodes?
Redis Cluster partitions the keyspace into 16384 hash slots, and each primary owns a subset of those slots.
2. What is the main limitation of plain Redis replication?
Every replica holds the full dataset, so replication scales reads and adds redundancy but cannot increase write throughput or total memory capacity.
3. Which component provides automatic failover for a non-clustered primary/replica setup?
Redis Sentinel monitors a primary and its replicas and promotes a replica automatically when the primary fails; Cluster has failover built in.
Flash Cards
Replication in one line? — Full dataset copied to read-only replicas for redundancy and read scaling.
Redis Cluster in one line? — Keyspace partitioned into 16384 hash slots across many primary shards, each with replicas.
Does replication scale writes? — No — writes still funnel through the single primary; only reads scale out.
How many hash slots in a cluster? — 16384 slots, distributed among the cluster's primary nodes.
Continue Learning
Related Interview Questions
How does sharding work in Redis Cluster with hash slots?
hard
How does live resharding work in Redis Cluster, and what can go wrong during slot migration?
hard
How should a client library route commands in Redis Cluster, and what happens during MOVED, ASK and failover?
hard
How does Redis Sentinel provide high availability?
medium