What does the "master-replica" model mean in Redis?
The master-replica model (formerly called master-slave) in Redis is a data-replication scheme where:
- Master (the main server) is the primary node, where all write operations go.
- Replica is one or several secondary nodes that copy the master's data and can be used for reads.
How this works:
- Replicas connect to the master and receive a full copy of its data.
- After that, the master forwards them a stream of changes (commands), so they stay in sync.
- Replicas can be used for reads, to take load off the master, but writes can only go to the master.
- If the master fails, one of the replicas can be promoted to master (manually, or automatically, via Redis Sentinel or Redis Cluster).
The model's goal:
- Improving fault tolerance (data is held on several nodes).
- Scaling reads (replicas handle read requests).
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.