Saturday, 4 May 2024

Quick Overview On Single Master And Multiple Slaves In Database World

In this post, Let's talk about how a single master and multiple slaves architectures helps to achieve redundancy and high availability to the databases.

 

Master Database: The master database is the primary node in the architecture. It handles all the write operations (INSERT, UPDATE, DELETE).

 

Slave Databases: The slave databases are replicas of the master database. They copy the data from the master and keep themselves synchronized with any changes made on the master. Slave databases handle read operations (SELECT) from applications.

 

In this way, we can distribute the read traffic among multiple slave nodes and reduce the load on master node.

 


 

As you see the above diagram, Application server do not contact the master or slave databases directly. There is a proxy layer, which is responsible to route all the WRITE operations to master database and all the READ operations to SLAVE databases. You can refer https://proxysql.com/ for more details.

 

 

What happen when a master went down?

If the master database goes down, one of the slaves can be promoted to become the new master, ensuring continuous availability of the database.

 

What if a slave went down?

Since there are multiple replica slave nodes, the READ traffic is still served.

 

Overall, a single master and multiple slaves architecture provides scalability, fault tolerance, and high availability for MySQL databases, making it a popular choice for many applications

 

 

References

https://proxysql.com/

https://learn.microsoft.com/en-us/azure/azure-sql/database/service-tiers-sql-database-vcore?view=azuresql


                                                  System Design Questions

No comments:

Post a Comment