当前位置:   article > 正文

kafka超时异常_kafka maximum size of batches returned in poll(wit

kafka maximum size of batches returned in poll(with max.poll.records.

kafka超时异常

Kafka Handle Error, Client Will Seek Soon: org.apache.kafka.clients.consumer.CommitFailedException: Commit cannot be completed since the group has already rebalanced and assigned the partitions to another member. This means that the time between subsequent calls to poll() was longer than the configured max.poll.interval.ms, which typically implies that the poll loop is spending too much time message processing. You can address this either by increasing the session timeout or by reducing the maximum size of batches returned in poll() with max.poll.records.
  • 1

因为一次性poll拉取(默认500)消息后处理时间过长,导致两次拉取时间间隔超过了max.poll.interval.ms阈值(默认五分钟),集群以为消费线程挂了,触发了rebanlance。当消费完了再去同步游标报错了,然后游标回滚,导致部分重复消费。

消费者参数
参数名框架默认值含义备注
fetch.max.wait.ms0.5s每次拉取最大等待时间和下面一个参数fetch.min.bytes配合使用
fetch.min.bytes1b每次拉取最小字节数只要有消息或者每隔0.5s拉取一次
heartbeat.interval.ms3s向协调器发送心跳的时间间隔和下一个参数session.timeout.ms参数配合使用,建议不超过session.timeout.ms的1/3
session.timeout.ms30s30s消费者不发送心跳认为消费者挂了配置太大会导致真死消费者检测太慢,太小会检测到假死,触发不必要的rebanlance。
max.poll.records50每次拉取条数
max.poll.interval.ms300s拉取时间间隔每次拉取的记录必须在该时间内消费完

6个参数是3对,通俗理解如下:

​ 1,2配合使用,告诉kafka集群,我消费者的处理能力,每秒至少能消费掉

​ 3,4配合使用,告诉kafka集群,在我没事情干的时候,多久尝试拉取一次数据,即使此时没有数据(所以要处理空消息)

​ 5,6配合使用,告诉kafka集群,什么情况你可以认为整个消费者挂了,触发rebanlance

【max.poll.interval.ms和session.timeout.ms区别】

​ KIP-62前只有session.timeout.ms参数

KIP-62后不通过poll()方法发送心跳,而是后台一个心跳线程,这就允许单次poll处理更长时间。不会因为单次处理超时假死引发不必要的rebanlance

max.poll.interval.ms 检测消费者处理线程死亡

session.timeout.ms 检测整个消费者死亡

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/人工智能uu/article/detail/734948
推荐阅读
相关标签
  

闽ICP备14008679号