Database Replication | System Design Part - 4
In the previous article, we have discussed about LoadBalancer and how it plays a key role in web servers scalability, Now in this part 4 of SYSTEM DESIGN SERIES, we will be talking about database replication which provides high performance, availability, and reliability for databases
The definition of database replication is very precisely quoted by Wikipedia, so let's see that first
“Database replication can be used in many database management systems, usually with a master/slave relationship between the original (master) and the copies (slaves)”
The master database generally deals with all the modifying operations like [write, update, delete], on the other hand, the slave database will deal with reading operations, All the modifications happening in the master database will be synced with salve databases in real-time.
In any application the number of read operations will be twice or thrice more compared to write / update operations hence we will be having more slave databases in a system.
From this architecture, we can assure system availability, because if we have only one slave database and if it goes down all the read operations will be routed to master, As soon as the issue is found the infected database is replaced with a new slave database.
If there are multiple slave databases, in that case, read operations will be routed to the remaining slave databases.
If the master database goes down, one of the slave databases will be promoted as a master database and parallelly a new slave database is created in place.
Let's see what are the advantages of using master/slave architecture in databases
- Good Performance: As the reads will be done from slave and write happen in master, the system can handle parallel processing which will provide good performance
- High Availability: As our databases are replicated, we can process data from different locations even though some of our databases are offline and make the system available all the time.
- Reliability: With database replication, we will be having multiple slave databases in different datacenters which can act as a backup to each other. whenever any center got down due to various reasons like electricity shortage, earthquakes, and other natural disasters, We can easily preserve the data.
Comments
Post a Comment