How does cascading replication work in Redis?
Cascading replication in Redis is a scheme where a replica can itself act as a data source for other replicas.
How this is set up
Usually every replica connects directly to the master. But in a cascading scheme:
- one or several replicas connect to another replica,
- which in turn receives data from the master.
So the chain looks like this:
javascript
master → replica1 → replica2 → replica3How synchronization works
- The master sends data to
replica1. - Replica1, once synced, becomes the source for replica2.
- Every update reaching the master gets passed further down the chain.
- Each replica maintains its own offset (
replication offset), to know which data it's already received.
Why this is needed
- Reducing load on the master, not every replica connects to it directly.
- Read scaling, a multi-level structure can be built, where lower levels serve read requests.
- Flexibility for geographic distribution, e.g. the data center closest to a region gets its data from an intermediate replica, not directly from the master.
Downsides
- Update latency grows with the length of the chain.
- If an "intermediate" replica goes down, all of its "children" lose their sync source.
- Redis doesn't manage this structure automatically, the administrator specifies which node each replica should replicate from (
REPLICAOF host port).
Summary: Cascading replication in Redis is a manual scheme where replicas can copy data not directly from the master, but from each other, to reduce load on the primary server and scale the system for reads.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.