当前位置:网站首页>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.
边栏推荐
猜你喜欢

概率与期望部分题解

【2022 DSCTF决赛wp】

After docker is deployed, mysql cannot connect

TCP的粘包拆包问题+解决方案

二叉搜索树问题

《PyTorch深度学习实践》第十一课(卷积神经网络CNN高级版)

Redis进阶

NACOS Configuration Center Settings Profile

Japan Sanitary Equipment Industry Association: Japan's warm water shower toilet seat shipments reached 100 million sets

【MyCat简单介绍】
随机推荐
数据库多表关联插入数据
UDP广播
性能提升400倍丨外汇掉期估值计算优化案例
真实字节跳动测试开发面试题,拿下年薪50万offer。
uniapp打包次数限制怎么办?只需两步就能解决
原来使Maya Arnold也能渲染出高质量作品!超赞小技巧
Takeda Fiscal 2022 First Quarter Results Strong; On Track to Achieve Full-Year Management Guidance
算法拾遗十五补链表相关面试题
更改小程序原生radio的颜色及大小
17-VMware Horizon 2203 virtual desktop-Win10 manual desktop pool floating (seventeen)
DevExpress中针对指定列进行百分比转换
Technical Analysis Mode (8) Double Top and Bottom
2022杭电多校六 1006-Maex (树形DP)
共享内存+inotify机制实现多进程低延迟数据共享
Day9 of Hegong Daqiong team vision team training - camera calibration
【工具配置篇】VSCode 常用使用总结
浮点数基础知识
vscode notes
typescript64-映射类型
(四)旋转物体检测数据roLabelImg转DOTA格式