Single-Master and Multi-Master Replication in DBMS
Prerequisite – Data Replication
Data replication is simply process of copying data from one database server to another database server so that all users can share same data without any inconsistency. Before understanding various models of replicating data it is very important to know why we need to replicate data.
Assume that you have Rs. 5000 in your bank account and today you went to an ATM and did a withdraw of Rs. 100. Now your account balance is Rs. 4900. Now if you go to any other branch of same bank amount in account will be Rs. 4900 only which means it is updated in all branches. In today’s scenario no matter from which branch of a particular bank you withdraw money it is still updated in all banks and reason behind it is Data Replication.
Scenario when data replication was not present :
Let us consider same example stated above. Now if data replication was not present, then branch of ATM from which you withdrew will only have your current balance as Rs. 4900. All other branches of bank will have information that your current bank balance is still Rs. 5000. However, in real world, data is replicated to all branches, and all banks get an update in their database that account balance of a person X is now Rs. 4900.
In conclusion, we can say that for consistency of data and improving system availability, data replication plays a very important role. After knowing about basic idea behind concept of replication, we will understand two types of data replication methods :Single-Master Replication, and Multi-Master Replication.
1. Single-Master Replication :
Single-Master Replication is where data replication is done in such a way that only one server manages master table and make updates and changes required. The copy of master table is replicated to slave servers or customers who are authorized to view, read, search data. Any write operation instructed by consumer is transferred to master server and it does changes demanded. Hence we can infer that these applications provide slaves with read-only feature and where writes are done only by master.
Figure – Single-Master Replication
Use cases of Single-Master Replication –
- Offloading Information and Monitoring Questions :
Every organization has its own On Line transaction Processing (OLTP) that manages transaction-oriented applications. In this case of usage, either whole data or subset of data from OLTP system is transferred to another database. The purpose behind transfer of data from master to slave database is to support queries in reporting.
The advantages of this usage are –
- It boosts transition processing efficiency as reporting load is eliminated from OLTP framework.
- It enhances query performance by upgrading user experience.
- Using warm StandBy server :
The usage of warm Standby servers is often preferred when companies want to enhance their data availability. In other words, warm StandBy is process in which there is a backup database system running in parallel to primary database system. In this, database servers are kept up to date with online network by replication concept and can be easily put back in event of production system failure. They can also be used for regular maintenance by graciously switching to standby servers to bring production server offline for regular maintenance.
2. Multi-Master Replication :
Multi-Master Replication is where data replication is done in such a way that data is replicated to a group of computers known as master systems and anyone can update database and update done by anyone is replicated to other systems as well. Here all members deal with client equally as writes can be done by any system.
If a bank has branches in two cities for say city X and city Y. In case system becomes unavailable for some duration in city X, customer queries and transactions can be managed by city Y. Once System in city X becomes available again or we can say it comes online then replication is done back immediately to it. Such arrangement facilities with advantages of single master replication where client write requests are transferred to master system available. Along with this, it also helps in load balancing of multiple masters where writes are done by any available system.
Figure – Multi-Master Replication
Use cases of Multi-master Replication –
- Availability of Writing –
As we know single-master replication system allows write operation to master database and all other slave databases are read to application. So if we want that replicated data should also be available for write access then, multi-master replication can be used because it gives additional write access to slave databases.
- Scalability of Writing –
Multi-master replication in write application allows use several database servers on different hosts to process write operations on their own master database independently of one another. The changes made can be reconciled afterward.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.