What are the pitfalls of reading and writing separation?

In the last article, I introduced the structure of one master and multiple slaves and the switching process to you. Today we will continue to talk about the application scenario of the one-master and multiple-slave architecture: read-write separation, and how to deal with the problem of read-write separation caused by master-slave delay.

The one-master-multiple-slave structure we mentioned in the previous article is actually the basic structure of read-write separation. Here, I will paste this picture again for your convenience.
insert image description here
The main goal of read-write separation is to share the pressure on the main library. The structure in Figure 1 is that the client (client) actively performs load balancing. In this mode, the connection information of the database is generally placed in the connection layer of the client. That is to say, it is up to the client to select the backend database for query.

Another architecture is that there is an intermediate proxy layer proxy between MySQL and the client, the client only connects to the proxy, and the proxy determines the distribution route of the request according to the request type and context.
insert image description here
Next, let's take a look at the characteristics of the client direct connection and the read-write separation architecture with proxy.
1. The client direct connection solution, because there is less proxy forwarding, the query performance is slightly better, and the overall structure is simple, making it easier to troubleshoot problems. However, for this solution, since it is necessary to understand the details of the back-end deployment, the client will be aware of operations such as active-standby switchover and library migration, and needs to adjust the database connection information. You may think that the client is too troublesome, with a lot of redundant information and ugly architecture. In fact, it is not necessarily true. Generally, such an architecture will be accompanied by a component responsible for managing the backend, such as Zookeeper. Try to let the business side only focus on business logic development. <

Guess you like

Origin blog.csdn.net/yzh_2017/article/details/128691718