MySQL Master/Slave replication and read/write Separation
The so-called read/write splitting is to prepare two types of MySQL Databases in advance, one for update (master) and the other for query (slave ). When the application system needs to update data, it calls the master and slave when querying data. The advantage of doing so is to share the business processing of a single database with multiple databases. It can also be understood as Server Load balancer, so there is a problem, when will the master data be synchronized to slave? At this time, Master-Slave replication is used. Master-Slave replication provides multiple ways to synchronize data from the Master to the Slave. For more information about how to practice, see other articles on the network.
The following figure shows the system structure:
As mentioned above, the use of Master-slave replication to achieve read/write splitting improves the load capacity of the system. In fact, a Master should be added to achieve high availability of the database system, in this way, even if any of the database servers goes down, the system service usage will not be affected.
For details about how to implement read/write splitting and high availability of the application system, see configuring multiple data sources in the spring Project, use the aop entry point to call the master data source based on methods such as save *, update *, and delete *, and call the slave Data Source Based on find *, get *, and query.