System Design: Redundancy & Replication Flashcards
What is synchronous database replication?
It’s when changes made to the primary database are immediately replicated to the replica databases before the write operation is considered complete.
In synchronous replication, there is a strong consistency between the primary and replica databases, as all changes made to the primary database are immediately reflected in the replica databases.
What is asynchronous replication?
Asynchronous replication is a type of database replication where changes are queued and replicated to the replica database at a later time.
In asynchronous replication, there is a delay between the write operation on the primary database and the update on the replica databases.
However, asynchronous replication can also have performance benefits, as write operations can be completed quickly without waiting for confirmation from the replica databases. In addition, if one or more replica databases are unavailable, the write operation can still be completed on the primary database, ensuring that the system remains available.
What is semi-synchronous replication?
Semi-synchronous replication is a type of database replication that combines elements of both synchronous and asynchronous replication. In semi-synchronous replication, changes made to the primary database are immediately replicated to at least one replica database, while other replicas may be updated asynchronously.
In semi-synchronous replication, the write operation on the primary is not considered complete until at least one replica database has confirmed that it has received and processed the changes. This ensures that there is some level of strong consistency between the primary and replica databases, while also providing improved performance compared to fully synchronous replication.
Give me an example of replication with Dynamo
Every DynamoDB table is automatically replicated across at least three Availability Zones within a single AWS region.
Another: DynamoDB automatically replicates writes across multiple AWS regions.
Give me an example of replication with a traditional SQL DB.
Writes go to the primary database (INSERT, UPDATE, DELETE).
The primary database records changes in a binary log (binlog).
Replicas pull data from the binlog and update themselves to match the primary.
Read queries are routed to replicas, reducing the load on the primary.