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
synchronous
orAsynchronous
. But it will happen continuously..So this process
Syncing data between database servers to increase availability
called 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
Master
which has permission toRead
andWrite
Data in Database.Other side, There will be few database servers called
Slaves
which has permission only forRead
the data.Master servers can be one or more... But Slaves will be more than masters,
(Depends on the purpose and data size)
Master
This master database can
Read
andWrite
data 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.
Slaves
Slaves
are only able toread
the 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
master
will handle and read data.Slaves are
fetching chances
frommaster databases
to keep themup to date
.
Conclusion
Master - Slave
is a way to increase the database availability and provideZero Down time
. But it will cost more data storage. Because, When we replicate5GB
of data over3 servers
, It will be3 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
scalability
andavailability
, Then go withReplication
Cheers....... 💪💪💪💪
-
thanks brother,, this is very usefull
-
Thanks b6 very useful
-
@dev_lak thanks bro
-
@Malith thx bro
-
Nice article
Thanks brother -
@rachitha Thx bro
-
Good article bro, awesome b6
-
@root Thx dude