当前位置:网站首页>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.
边栏推荐
- typescript63-索引签名类型
- (2022杭电多校六)1010-Planar graph(最小生成树)
- Unable to import torchvision. IO. Read_image
- 腾讯业务安全岗 IDP 谈话总结
- Redis
- HelloWorld
- typescript62-泛型工具类型(record)
- PCI Pharma Services Announces Multi-Million Dollar Expansion of UK Manufacturing Facility to Meet Growing Demand for Global High Potency Drug Manufacturing Services to Support Oncology Treatment
- 【5】Docker中部署MySQL
- JS控制只能输入数字并且最多允许小数点两位
猜你喜欢
随机推荐
VS Code私有服务器部署(私有化)
《PyTorch深度学习实践》第十一课(卷积神经网络CNN高级版)
在小程序中关于js数字精度丢失的解决办法
蓝牙gap协议
lingo入门——河北省第三届研究生建模竞赛B题
17-VMware Horizon 2203 虚拟桌面-Win10 手动桌面池浮动(十七)
Matplotlib plotting notes
UDP group (multi)cast
自媒体人一般会从哪里找素材呢?
MyCat安装
cs231n learning record
typescript65-映射类型(keyof)
性能提升400倍丨外汇掉期估值计算优化案例
在STM32中使用printf函数
17-VMware Horizon 2203 virtual desktop-Win10 manual desktop pool floating (seventeen)
Mysql主从延迟的原因和解决方案
2022起重机司机(限桥式起重机)考试题库及模拟考试
protobuf根据有关联的.proto文件进行编译
#Sealos#使用工具部署kubernetesV1.24.0
MyCat配置文件









