Single-Leader Replication
Summary: A replication model where one node (the leader) accepts all writes and propagates changes to other nodes (followers) via a replication log or change stream.
Sources: chapter5
Last updated: 2026-04-15
In single-leader replication (also known as active/passive or master-slave replication), each node that stores a copy of the database is called a replica. One of the replicas is designated as the leader (master or primary). When clients want to write to the database, they must send their requests to the leader, which writes the new data to its local storage (source: chapter5, p. 152).
The leader also sends the data change to all its followers (read replicas, slaves, or hot standbys) as part of a replication log or change stream. Each follower takes the log from the leader and updates its local copy of the database accordingly (source: chapter5, p. 152).
Features
- Writes: Only the leader accepts writes (source: chapter5, p. 152).
- Reads: Clients can query either the leader or any of the followers. However, writes are only accepted on the leader (source: chapter5, p. 153).
- Popularity: This is the default mode for many relational databases (MySQL, PostgreSQL, Oracle, SQL Server) and some non-relational ones (MongoDB, RethinkDB, Espresso) (source: chapter5, p. 153).
Synchronous vs. Asynchronous Replication
- Synchronous: The leader waits until the follower has confirmed that it received the write before reporting success to the user. This ensures the follower has an up-to-date copy but can block all writes if the follower fails (source: chapter5, p. 154).
- Asynchronous: The leader sends the message but doesn’t wait for a response. This is more common in practice because it doesn’t block writes, even if followers are lagging or unavailable (source: chapter5, p. 154).
Handling Node Outages
- Follower failure: A follower can recover easily by connecting to the leader and requesting all data changes that occurred while it was disconnected (source: chapter5, p. 156).
- Leader failure (Failover): One of the followers needs to be promoted to be the new leader, and clients need to be reconfigured to send their writes to the new leader. This process is called failover (source: chapter5, p. 157).