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 –
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.
Unlock the Power of Placement Preparation!
Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation
Course is the ultimate guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation