DEBUG.WIKI
阿里云;从建站到云上业务;云服务器 · 数据库 · 对象存储;查看产品 →
PanstarCloud:部署应用,接入 AI,云服务器与 AI 网关
IPPeak:从目标地区访问网页,住宅代理、SEO 监测、广告验证

解决 RocketMQ 报错 RemotingTimeoutException BROKER_BUSY 忙碌超时修复

排查 RocketMQ 生产端发送消息报 RemotingTimeoutException: wait response timeout 或 BROKER_BUSY,分析 pagecache 锁与写入队列优化。

问题现象

业务高峰期向 RocketMQ Broker 发送消息时频繁失败:

org.apache.rocketmq.remoting.exception.RemotingTimeoutException: wait response on the channel <192.168.1.20:10911> timeout, 3000(ms), send message failed
[CODE: 2] system busy, start flow control for a while

触发根因

  1. Broker 物理磁盘 IO 瓶颈导致 PageCache 刷盘锁时间过长,触发了系统的 waitTimeMillsInSendQueue 阈值保护;
  2. 开启了同步刷盘(SYNC_FLUSH)且宿主机使用了低性能机械硬盘;
  3. 垃圾回收导致 JVM 发生长时间 Full GC。

解决步骤

调整 Broker 忙碌流控等待容限

在 broker.conf 中调整:

waitTimeMillsInSendQueue=1000
osPageCacheBusyTimeOutMills=2000

启用堆外内存缓存池(TransientStorePool)

实现读写分离以削减 PageCache 锁竞争:

transientStorePoolEnable=true
warmMapedFileEnable=true

验证确认

重启 Broker 节点:

nohup sh mqbroker -c ../conf/broker.conf &

生产端发送延迟降至个位数毫秒,流控告警彻底消失。