MongoDB flow control
2023-10-27 15:56 abce 阅读(159) 评论(0) 编辑 收藏 举报从 MongoDB 4.2 开始,管理员可以限制主节点的写入速度,目的是将多数提交的延迟保持在可配置的最大值 flowControlTargetLagSeconds 以下。
默认情况下, flow control 是启用的。
启用 flow control 后,当延迟时间接近 flowControlTargetLagSeconds 时,主节点上的写操作必须先获得票据,然后才能加锁应用写操作。通过限制每秒签发的票据数量, flow control 机制试图将延迟保持在目标值以下。
查看 flow control 的状态
1 2 3 4 5 6 7 8 9 10 11 | > db.serverStatus().flowControl { enabled: true , targetRateLimit: 1000000000, timeAcquiringMicros: Long( "134209790" ), locksPerKiloOp: 4, sustainerRate: 1000, isLagged: false , isLaggedCount: 19, isLaggedTimeMicros: Long( "18991175" ) } |
1.运行 rs.printSecondaryReplicationInfo() 确认是否有节点发生了延迟
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | > rs.printSecondaryReplicationInfo() source: 11.12.10.28:27017 { syncedTo: 'Fri Oct 27 2023 15:24:46 GMT+0800 (China Standard Time)' , replLag: '0 secs (0 hrs) behind the primary ' } --- source: 11.12.10.30:27017 { syncedTo: 'Fri Oct 27 2023 15:24:46 GMT+0800 (China Standard Time)' , replLag: '0 secs (0 hrs) behind the primary ' } --- source: 192.168.16.15:27017 { syncedTo: 'Fri Oct 27 2023 15:24:46 GMT+0800 (China Standard Time)' , replLag: '100 secs (0 hrs) behind the primary ' } |
2.运行 serverStatus 命令并使用 flowControl.isLagged 值确定副本集是否已遇到 flow control:
1 2 | > db.runCommand( { serverStatus: 1 } ).flowControl.isLagged false |
如果结果为false,就需要去副本节点上查看延迟的原因了。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
2020-10-27 PostgreSQL记录中的null值是如何存储的