kafka消息堆积原因解析

kafka消息堆积,可以调节如下两个参数

max.poll.records

一次调用poll()返回的最大记录数。
默认值500 就是一次最多拉取500条记录

max.poll.interval.ms

  • max.poll.interval.ms参数用于指定consumer两次poll的最大时间间隔(默认5分钟),如果超过了该间隔consumer client会主动向coordinator发起LeaveGroup请求,触发rebalance;然后consumer重新发送JoinGroup请求
  • Kafka 重平衡过程中是不能消费的,会导致消费组处于类似 stop the world 的状态下,重平衡过程中也不能提交位移,这会导致消息重复消费从而使得消费组的消费速度下降,导致消息堆积
  • 表示你的 Consumer 程序如果在 5 分钟之内无法消费完 poll 方法返回的消息,那么 Consumer 会主动发起 “离开组” 的请求,Coordinator 也会开启新一轮 Rebalance。

The maximum delay between invocations of poll() when using consumer group management. This places an upper bound on the amount of time that the consumer can be idle before fetching more records. If poll() is not called before expiration of this timeout, then the consumer is considered failed and the group will rebalance in order to reassign the partitions to another member.

总结

消息堆积就是消费者消费的慢了,导致broker消息堆积,而如果消费者的代码没变的话,慢的原因可能是因为参数设置不合理导致不停的重复消费.

参考

Kafka 中文文档 - ApacheCN

Kafka配置max.poll.interval.ms参数_yuanpanni的博客-CSDN博客

记一次线上Kafka消息堆积踩坑总结_xiaoguozi0218的博客-CSDN博客_kafka一次poll多少数据

一次 kafka 消息堆积问题排查_后端进阶-CSDN博客_kafka 问题排查

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值