MySQL master-slave replication and read-write separation, mysql master-slave read-write

Source: Internet
Author: User

MySQL master-slave replication and read-write separation, mysql master-slave read-write

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.


Q: 1. What is the concept of mysql master-slave replication? In some cases, it is best to give an example;

1. Master-slave replication is used to build a database environment exactly the same as that of the master database, called a slave database. The master database is generally a real-time business database, the functions and usage of databases generally include:
First, as a backup database, after the master database server fails, you can switch to the slave database to continue working;
Second, backup and data statistics can be performed from the database, without affecting the performance of the primary database;
2. read/write splitting refers to the use of different databases for reading and writing, of course, generally on different servers. The read/write environment on the same server is only used for testing.
In general, the configuration of the read/write database environment is: one written database, one or more read databases, each database is located on a different server, making full use of the server performance and database performance; of course, it involves how to ensure data consistency between read and write databases, which can be achieved through master-slave replication technology.
The general application scenario is: the service throughput is large, and the load for reading databases (which can be simply understood as the proportion and impact of select statements) is large;
The official mysql-proxy is a software that implements multiple functions such as read/write splitting and Server Load balancer.
 
After mysql implements master-slave replication, what can be done to achieve load balancing, or can it be implemented directly without doing anything?

Functions provided by MySQL During master-slave Replication
If you want to implement Server Load balancer,
I am studying the use of Amoeba for read/write splitting. I suggest you search for some posts about mysql Server Load balancer on the Internet.
Of course, MySQL Proxy is also used for read/write splitting. I don't know if I can help you.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.