Master-Slave and Multi-Master Database Replication (Quick Notes)

Database replication is usually done to achieve HA (High Availability). Following are the 2 common modes of replication:

  • Master-Slave replication
  • Mater-Master replication
Master-Slave replication

In this mode of replication, one machine (master server) has unidirectional control over one or more other (slave) machines. The writes are and can only be done through master-machine, while slave-machines are used for reads.
It is used for load-sharing purposes. A single member of group is designated as master for a given piece of data and is the only node allowed to modify data. Other nodes that wish to modify the data must first contact the master node. Thus, writes are done only on the master which then propagates the change to slave nodes.
Since this mode of replication, allows only the master node to modify the data, it makes it easier to achieve consistency among the nodes.

Master-Master replication

Master-Master replication allows updates to be submitted to any node/machine, which then ripple through to other nodes. The writes and reads in this mode could be done via any node. It does increase the writing cost. However, multi-master replications major purposes are increased availability and faster server-response time. If one node fails, other masters continue to update the database.
The most common challenge it presents is transaction-conflict (consistency) prevention. For instance, if a database record is changed on two nodes simultaneously. It becomes difficult to achieve consistency and causes ambiguity. (Generally, inconsistency is resolved via transaction’s timestamp. However, it still fails to prevent data-collision completely).

2 thoughts on “Master-Slave and Multi-Master Database Replication (Quick Notes)

Leave a Reply

Your email address will not be published. Required fields are marked *