当前位置:网站首页>Mysql master-slave delay reasons and solutions
Mysql master-slave delay reasons and solutions
2022-08-05 07:03:00 【Eat well without getting fat】
MySQL master-slave replication
First of all, there are two main ways of binlog recording (excluding Mixed)
statement--SBR operation-based SQL statementAdvantages: It is not necessary to record the changes of each SQL statement and each row of data, which reduces the amount of binlog logs, saves I/O, and improves performance.Disadvantage: In some cases, the primary and secondary data are inconsistent.row---RBR based on row changes (data records before and after changes)Advantages: It does not record the context information of each SQL statement, but only records the detailed modification details of the data, which is the safest.Disadvantage: Generates a lot of logs and consumes disk space.The master-slave replication process of MySQL can refer to the following article, which is omitted here.
Master-slave replication process
Master-Slave Delay
At t1, the main library executes the transaction and writes it to the binlogAt time t2, the slave library receives the binlog (IO thread) of the main library and writes to the relay logAt time t3, the SQL thread of the slave library executes the SQL statement to complete the transactionThe master-slave delay means that the time difference between the completion of the execution of the slave library and the completion of the execution of the main library is greater than (t3-t1)Possible causes and solutions for master-slave delay
1) Hardware differences between master and slave servers.The performance of the slave database machine is poor, and the data of the master database cannot be synchronized in time. It is only necessary to replace the new device or keep the same device.
2) The reading pressure from the library is high.Generally, the main library "writes" and the slave library "reads".A large number of "read" requests hitting the slave library will consume a lot of system resources of the slave library, thereby affecting the synchronization speed of the slave library.At this time, a master-multiple-slave architecture can be built to share the pressure of "read" requests.
3) Big business.If the transaction is executed in the master database for 15 minutes, the synchronization in the slave database will also take at least 15 minutes, resulting in master-slave delay.Transactions are done in batches if possible.
4) Network latency.The network communication status will also affect the master-slave replication (affecting the IO thread of the slave library to obtain the master library binlog), only the bandwidth can be upgraded and the network can be optimized.
5) Too many libraries.Generally, 3-5 slave nodes are the best.
边栏推荐
猜你喜欢

Shiny04---DT和进度条在shiny中的应用

uniapp打包次数限制怎么办?只需两步就能解决

给网站套上Cloudflare(以腾讯云为例)

typescript63-索引签名类型

亚马逊美国站:马术头盔CPC认证标准要求

蓝牙gap协议
![In-depth analysis if according to data authority @datascope (annotation + AOP + dynamic sql splicing) [step by step, with analysis process]](/img/b5/03f55bb9058c08a48eae368233376c.png)
In-depth analysis if according to data authority @datascope (annotation + AOP + dynamic sql splicing) [step by step, with analysis process]

不太会讲爱,其实已经偷偷幸福很久啦----我们的故事

字节面试流程及面试题无私奉献,吐血整理

2022起重机司机(限桥式起重机)考试题库及模拟考试
随机推荐
Hong Kong International Jewellery Show and Hong Kong International Diamond, Gem and Pearl Show kick off
typescript65-映射类型(keyof)
2022杭电多校六 1007-Shinobu loves trip(同余方程)
UDP组(多)播
蓝牙gap协议
Shiny04---DT和进度条在shiny中的应用
【Go】IM系统Centrifugo
今天虚竹哥又发现了一款好用的国产化API工具
lingo入门——河北省第三届研究生建模竞赛B题
如何将.asd恢复为Word文档
Redis
lingo入门——河北省第三届研究生建模竞赛B题
Shared memory + inotify mechanism to achieve multi-process low-latency data sharing
Advanced Redis
淘宝客APP带自营商城本地生活CPS外卖优惠电影票话费更新渠道跟单生活特权V3
概率与期望部分题解
真实字节跳动测试开发面试题,拿下年薪50万offer。
Week 8 Document Clustering(文本聚类)
【JVM调优】Xms和Xmx为什么要保持一致
How to avoid online memory leaks