Databases 4 min read

Understanding Redis Master‑Slave Replication: Full and Incremental Sync Explained

This article explains Redis master‑slave replication, covering the roles of master and replica, the full‑copy synchronization process, the incremental sync mechanism, and the step‑by‑step workflow illustrated with diagrams to help engineers implement reliable high‑availability data stores.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Understanding Redis Master‑Slave Replication: Full and Incremental Sync Explained

Redis Master‑Slave Replication Overview

Redis provides a master‑slave replication feature that enables read‑write separation and high availability. The master node handles all write operations and propagates data changes to one or more replica (slave) nodes, which primarily serve read requests.

Replication Mechanism

Replication consists of two phases: a full (initial) copy and an incremental (continuous) sync.

1. Full Synchronization

Trigger scenario: When a replica connects to the master for the first time.

Characteristics: All data is transferred, which can be time‑consuming and bandwidth‑intensive, but guarantees complete data consistency.

Process:

Replica sends PSYNC ? -1 request to the master.

Master runs BGSAVE to generate an RDB snapshot.

Master streams the RDB file to the replica.

Replica clears its old data and loads the received RDB.

Master sends any buffered write commands; replica executes them.

Full sync completes and replication switches to incremental mode.

2. Incremental Synchronization

Trigger scenario: After a brief disconnection, the replica reconnects to the master.

Characteristics: Only commands generated during the outage are transferred, resulting in fast, low‑overhead synchronization.

Process:

Replica sends PSYNC <runid> <offset> to the master.

Master checks its replication backlog for the requested offset.

If the offset exists, the master streams only the missing commands (incremental sync).

If the offset is missing, the master falls back to a full synchronization.

Replica applies the received command stream to catch up with the master.

These steps ensure that replicas stay up‑to‑date with minimal latency while providing a reliable fallback to full sync when necessary.

RedisMaster‑Slave
Mike Chen's Internet Architecture
Written by

Mike Chen's Internet Architecture

Over ten years of BAT architecture experience, shared generously!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.