Mysql replication from the primary response to high concurrency

Million level, index optimization, SQL query optimization

  Here's an article I wrote before: https://blog.csdn.net/star1210644725/article/details/88615290

 Sub-library sub-table will be used to read and write separation, because the use of different storage engines to the scene to deal with read and write scenarios, respectively.

 It uses separate read and write, you must use the master-slave replication, for example, we need to write data to a library inside, in addition to a library of reading, which take into account the problem of data synchronization.

Then talk about the problem of high concurrency 

 As the name suggests, high concurrency is going to deal with a lot of things per second.

  In fact, the so-called high concurrency solution is dispersed pressure. Stand-alone physical bottleneck is unable to break through, like reading and writing speed of the disk, there must be some limit, like the processing power of the CPU there is a limit.

  So what are viable options?

  Use cache redis, redis is a memory-based database, which has a very high literacy rate.

  Using the clipping message queue, asynchronously loaded.

  Separate read and write

  In addition to the physical limits it is to solve the problem, since the stand-alone not, then multiple machines together to deal with.

Plays Today: master-slave replication

 The concept is this, we want to write a machine, a machine reading (there is a demand, then you can read a number of machines, number of machines to write), then we need to ensure that the two databases inside the data is the same, that is, to ensure that the data consistency. It has a problem: the problem of data synchronization, two wants the same database data, how data sync it?

 data synchronization:

 master writes the main library will keep a binlog (binary log), the main library writes data in it from the library playback, the data can be synchronized.

Think I do it again the case, then recommend a post (concrete operations have to be followed here): https://www.cnblogs.com/clsn/p/8150036.html

 From the main build a good future, say a few pit:

 In the interpolated data from the library inside, it is a pit, cause data to not sync.

Master-slave replication diagram:

 主库的所有写操作都记录在binlog里边去,从库和主库建立好联系以后,就安排一个线程负责监控binlog的动静,binglog发生改变,立马将变化的地方告诉自己的Realylog(中继日志),然后再安排一个进程负责监控中继日志的变化,一旦变化了立马更新自己的数据库内容。

  监控的线程是单线程的,这是主从复制演示问题的主要来源。mysql5.7以后可以使用多线程。

 

Guess you like

Origin blog.csdn.net/star1210644725/article/details/92994638