Redis Replication Architecture
What you'll learn: How Redis achieves high availability and read scalability through master-replica replication with asynchronous data synchronization.
The Core Idea
Redis replication uses a master-replica (formerly master-slave) architecture where one primary Redis instance accepts writes, and one or more replica instances maintain copies of that data. The master propagates changes to replicas asynchronously, meaning the master doesn't wait for replicas to confirm receipt before acknowledging a write to the client.
Think of it like a teacher (master) lecturing while students (replicas) take notes. The teacher keeps talking without waiting for every student to finish writing each sentence. Students are usually caught up, but might be a few words behind.
How It Works
When you write to a Redis master:
- The master processes the write immediately
- The write is added to a replication stream
- Replicas asynchronously pull or receive this stream
- Replicas apply changes in the same order
Replicas are read-only by default — you can scale read operations across multiple replicas while all writes go to the master.
Eventual Consistency
Because replication is asynchronous, replicas experience replication lag — a brief delay before they reflect the master's latest state. This means Redis offers eventual consistency: replicas will eventually match the master, but at any given moment might be slightly behind.
If the master fails before replicas catch up, recent writes could be lost — this is the trade-off for high performance and availability.
Architecture Benefits
- Read scalability: Distribute read load across replicas
- High availability: Replicas can be promoted to master if it fails
- Geographic distribution: Place replicas closer to users
Key Takeaway: Redis replication provides high availability and read scalability through asynchronous master-replica architecture, trading strong consistency for performance and accepting potential replication lag.