- This is the critical system design.
- As it needs to provide redundancy , scalability and fault tolerance.
- It tells the replication between primary database and its replicas.
Synchronous replication
- data changes are replicated to one or more replicas in real time.
- The transaction is not committed until one replica has acknowledged.
- primary database and its replicas are always in sync, providing a high level of data consistency.
- Example --> Banking application uses synchronous replication to ensure that all transactions are replicated to a secondary database in real-time for data consistency and disaster recovery purposes.
Working
Benefits
- Strong Data Consistency --> Synchronous replication ensures that all replicas are up-to-date with the primary database.
- Data Durability --> Since the transaction is not considered committed until it is replicated to at least one replica.
Challanges
- Performance Impact --> as it must wait for acknowledgment from the replica(s) before completing transactions.
- Network Latency --> as the primary database must wait for acknowledgment from the replica(s) over the network.
Asynchronous replication
- data changes are replicated to one or more replicas after they are made on the primary database, without waiting for acknowledgment from the replicas.
- faster transaction processing on the primary database.
- slight delay in data consistency between the primary and replica(s).
- Example --> An e-commerce website uses asynchronous replication to replicate product inventory data from the primary database to a secondary database for reporting and analysis purposes.
Working
Benefits
- Improved performance on the primary database and reduced sensitivity to network latency. By not waiting for acknowledgment from the replicas before committing transactions.
- Network Latency --> As it does not require immediate acknowledgment from the replicas
Challanges
- Data Consistency --> Delay in data consistency between the primary database and its replicas, as the replicas are updated after the changes are made on the primary database.
- Data Loss --> In case of a failure on the primary database before the changes are replicated to the replicas, there is a risk of data loss as the changes may not be replicated.
Semi-synchronous replication
- method that combines aspects of synchronous and asynchronous replication.
- data changes are replicated to at least one replica synchronously, ensuring strong data consistency for critical data, while other replicas are updated asynchronously for better performance.
- balance between strong data consistency and improved performance.
- Example --> When a customer initiates a funds transfer transaction, the transaction is processed on the primary database --> changes made by the transaction are replicated synchronously to at least one replica to ensure strong data consistency for critical financial data --> Other replicas are updated asynchronously to improve performance.
Working
Benefits
- Strong Data Consistency --> strong data consistency for critical data by replicating changes synchronously to at least one replica.
- Improved Performance --> other replicas asynchronously, semi-synchronous replication improves performance compared to synchronous replication.
Challanges
- Increased complexity and resource usage compared to asynchronous replication, which must be carefully managed for optimal performance.
- Synchronous updates can impact the performance of the primary database and increase resource usage compared to asynchronous replication. [ TBD ]
Differences
How to choose Replication Configuration ?
- Data Consistency Requirements
- Performance Requirement
- Network Bandwidth and Latency
- Failover and High Availability
- Data Loss Tolerance
CONCLUSION
Database replication modes offer various trade-offs in terms of data consistency, performance, and complexity .
Notes
- redundancy means duplicating critical components so a system does not fail if one part breaks.
- fault tolerance --> system's ability to keep operating without interruption when one or more of its hardware or software components fail.
- A trade-off is a situation where you give up one thing or quality in order to get or keep another, usually because you cannot have both at the same time









Top comments (0)