What is 🛢Database Replication?
Database Replication is a mechanism whereby data is available in more than one location. It means, Having more than one database server and replicating all the data in all available database servers.
Why Database Replication ?
The Data-Centers or Large Scale Application Systems are handling millions of queries per second. This kind of continuous huge requests can create very very huge traffic and collision over the network. So there are many possibilities for Server Brake Down or Down Time .
To avoid this, If one database server fail, We need to provide data from another server until the failed server up again. And also we can reduce a load of a server by having more database instances .
For that we need no sync data from a main server to other servers. This syncing process can be
Asynchronous. But it will happen continuously..
So this process
Syncing data between database servers to increase availabilitycalled Replication.
Master - Slave Architecture
In Database Replication, Most Engineers go with a very efficient architecture called Master - Slave.
In this architecture there will be database server called
Masterwhich has permission to
WriteData in Database.
Other side, There will be few database servers called
Slaveswhich has permission only for
Master servers can be one or more... But Slaves will be more than masters,
(Depends on the purpose and data size)
This master database can
Writedata in Database, But mostly used to write data.
When application wants to write the data, The query or request will be forwarded to one of the master server.
And also masters will sync the data to their slaves.
Slavesare only able to
readthe data from database. So when application want to read a data, The query or request will be forwarded to one of the slave.
When slaves down, and there are no slaves to handle, The
masterwill handle and read data.
master databasesto keep them
up to date.
Master - Slaveis a way to increase the database availability and provide
Zero Down time. But it will cost more data storage. Because, When we replicate
5GBof data over
3 servers, It will be
3 x 5 = 15GB.
Current Databases are much faster than before. So it is not compulsory to implement replication for smaller level projects.
But when you want more
availability, Then go with
dev_lak last edited by
thanks brother,, this is very usefull
Thanks b6 very useful
@dev_lak thanks bro
@Malith thx bro
rachitha last edited by
@rachitha Thx bro
Good article bro, awesome b6
@root Thx dude