Database replication refers to the frequent copying of data from one node, that is, a database on one server, to a node on another server. A database replication system is, in other words, a distributed database in which all nodes share the same level of information. This system is also known as a database cluster.
The database client (such as a Web browser or a computer application) does not see the database replication system in any way, but experiences close to native DBMS behavior.
Many database management systems replicate databases. The most common replication method is to create a master/slaves relationship between the original data set (master) and its copies (slaves). The master logs the updates to the data, and propagates the logs through a network to the slaves. The slaves, for their part, receive a stream of updates from the master and apply the changes accordingly.
A master/slaves relationship is depicted in the figure below:
Master/Slave Replication
Another common replication method is to create a multi-master replication system, where updates can be submitted to any database node, and then propagated through a network to other database nodes. In other words, all database nodes act as masters, and no logs or update success indications are sent.
A multi-master replication system is depicted in the figure below:
Multi-master Replication
From a more technical perspective, asynchronous and synchronous replication protocols differ in the way they propagate database transactions to other nodes in the database cluster:
Theoretically, synchronous replication has several advantages over asynchronous replication:
Traditionally, eager replication protocols coordinated nodes one operation at a time, using 2-phase commit or distributed locking. In a system with x nodes and y operations, a throughput of z transactions per second requires x × y × z messages per second. When the number of nodes increases, transaction response times, conflict probability and deadlock rates grow exponentially. This has led to a situation where asynchronous replication remains the dominant means for database performance scalability and availability. Widely adopted open-source databases such as MySQL or PostgreSQL only offer asynchronous replication solutions.
To solve the problems in the traditional synchronous replication systems and approaches, researchers all around the world have, in the last couple of years, suggested alternative approaches to synchronous database replication. In addition to theory, prototype implementations have shown a lot of promise. The most important improvements these studies have brought about are:
Galera Cluster‘s certification based replication builds on these approaches.