Database Replication in System Design (original) (raw)

Last Updated : 17 Apr, 2026

Making and keeping duplicate copies of a database on other servers is known as database replication. It is essential for improving modern systems' scalability, reliability, and data availability.

**Example: An e-commerce website may use a primary database for write operations and multiple replica databases to handle read requests from users.

Working

These steps explaining how database replication works:

server

Working of Database Replication

  1. **Identify the Primary Database (Source): A primary (master) database is selected as the main source where all data changes originate.
  2. **Set Up Replica Databases (Targets): One or more replica databases are configured to receive data from the primary database.
  3. **Capture Data Changes: All inserts, updates, and deletes are recorded using logs or change data capture mechanisms.
  4. **Transmit Changes to Replicas: Captured changes are sent to replica databases either in real-time or at scheduled intervals.
  5. **Apply Changes on Replicas: Replica databases apply the received updates to stay synchronized with the primary database.
  6. **Monitor Synchronization: The system continuously checks replication status and resolves delays or synchronization issues.
  7. **Handle Read/Write Operations: Read operations are distributed across replicas, while write operations typically go to the primary database (depending on the model).

Types of Database Replication

Understand the different types of database replication:

types_of_database_replication

1. Master-Slave Replication

In this replication model, one database acts as the primary server while others maintain copies of its data.

2. Master-Master Replication / Multi-Master Replication

In this setup, multiple databases act as masters and can accept both read and write operations.

3. Snapshot Replication

This method replicates the entire database by taking a snapshot at a specific point in time.

4. Transactional Replication

Transactional replication synchronizes databases by replicating changes as they occur.

5. Merge Replication

Merge replication allows multiple databases to update data independently and later synchronize the changes.

Strategies

Database replication strategies determine how to select data, copy and distribute it between databases to gain specific goals such as scalability, availability, and efficiency.

Some common database replication strategies include the following:

Configurations

To accomplish particular objectives related to data consistency, availability, and performance, database replication can be set up and run in a variety of ways:

1. Synchronous Replication Configuration

In synchronous replication, data changes are replicated to replicas immediately before the transaction is completed.

2. Asynchronous Replication Configuration

In asynchronous replication, the primary database sends updates to replicas without waiting for confirmation.

3. Semi-synchronous Replication Configuration

Semi-synchronous replication is a hybrid approach that combines features of synchronous and asynchronous replication.

Importance

Database replication is important for several reasons:

Challenges

Some of the challenges with Database Replication are: