What does a replica do in a cluster?
In Redis Cluster, a replica performs several key functions, but on its own it doesn't hold any slots - it copies its master's data.
1. Copying the master's data
- A replica syncs with a master node and receives a full copy of every slot the master serves.
- Replication is asynchronous: the master doesn't wait for the replica's acknowledgment when writing.
2. Providing fault tolerance
- If the master fails, its replica is automatically promoted to master.
- The rest of the cluster's replicas and nodes learn about it through Gossip.
- That lets the cluster keep running with no manual intervention.
3. Scaling reads
- Replicas can be used to serve read requests, taking load off the master.
- Reading from replicas helps scale throughput without increasing load on the primary node.
4. Important points
- Replicas don't acquire new slots on their own, they only copy their master's data.
- Every replica is tied to a single master and can't serve other masters' slots.
- A replica can have several downstream read clients, but writes always go through the master.
Summary
A replica in Redis Cluster:
- Copies its master's data.
- Provides fault tolerance (auto-failover).
- Scales reads, reducing load on the master.
It doesn't hold slots itself, but it provides resilience and boosts the cluster's throughput.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.