The so-called read and write separation is the preparation of two types of MySQL database, a update operation (master), a query operation (slave). Call Master when the application needs to update data and invoke slave when querying data. The benefit of doing this is to share the business processing of a single database with multiple databases, or load balancing, so there is a problem when Master's data is synchronized to slave in what way? This time to use the master-slave replication, master-slave replication provides a number of ways to synchronize the master data into the slave, how to practice please refer to other articles on the network.
Below is a picture of the system structure:
On the top of the use of master-slave replication to achieve read and write separation to improve the load capacity of the system, in fact, you should add a master to achieve high availability of the database system, so that any one of the database server downtime does not affect the system business use.
about how the application system realizes read-write separation, high availability according to the specific project situation, for example: Configure multiple data sources in the spring project, use the AOP pointcut to call the master data source according to Save*, update*, delete* and so on, according to Find*, get*, Query* to invoke the slave data source.
MySQL master-slave replication and read/write separation