Redis & Caching (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
How does Master-Replica Replication work in Redis?
senior LevelSystem Design
In Simple Words: Replication is asynchronous:
- Initial Sync (Full Resync): Master runs
bgsaveto create an RDB snapshot and sends it over the network to the Replica. - The replica loads the RDB file into memory.
- Master buffers new writes in the Replication Backlog Buffer and streams them to the replica continuously.
- Partial Resync (PSYNC): If a replica briefly disconnects, it reconnects using its offset and fetches only missing delta bytes from the backlog buffer without a full RDB transfer.