High Scale Replication
Scale your reads by distributing data across multiple replicas. Understand how Redis keeps all nodes in sync with minimal latency.
MASTER
Writable
k1:v1
k2:v2
REPLICA 1
Read-Only
CONNECTED
k1:v1
k2:v2
REPLICA 2
Read-Only
CONNECTED
k1:v1
k2:v2
Full Resync
Occurs when a new replica joins or when a replica has been offline for too long. Master sends an entire RDB file.
Partial Resync (PSYNC)
Modern Redis allows replicas to "catch up" by only receiving the missing commands from the backlog buffer.
Replication ID
A random string used by replicas to verify they are talking to the same Master after a reconnection.
Asynchronous Logic
Replication in Redis is asynchronous by default. The Master doesn't wait for Replicas to confirm receipt of data before responding to the client.
Pros & Cons
- ✅ Low latency (Master isn't blocked)
- ✅ Read scaling (Handle millions of reads)
- ❌ Potential data loss if Master fails before propagation
The Replication Backlog
Redis maintains an in-memory buffer called the Backlog.
When a replica reconnects, it checks its offset against the Master. If the missing data is still in the backlog, a Partial Resync occurs. If not, a heavy Full Resync is required.
Tip: Increase `repl-backlog-size` for unstable networks.
Replication Flow
1. Handshake
Replica connects and sends PING. Master responds with PONG.
2. PSYNC Request
Replica asks for data from its last known replication offset.
3. Data Stream
Master streams all new writes to the replica in real-time.