【发布时间】:2019-09-27 13:15:26
【问题描述】:
我使用 spring-kafka 库开发了 Kafka 消费者应用程序,并使用了手动提交的默认消费者配置。
我正在运行两个应用程序实例,监听两个不同的 Kafka 主题。在执行负载测试时,我观察到我只有一个应用程序的负载低于错误:
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.
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.
\n org.apache.kafka.clients.consumer.internals.ConsumerCoordinator.sendOffsetCommitRequest(ConsumerCoordinator.java:725)
我阅读了几篇文章,发现如果消费者花费大量时间处理消息并且代理没有获得有关消费者活跃度的信息,那么消费者重新平衡就会发生,并且对于未提交的消息将抛出上述异常。
我已通过将 max.poll.interval.ms 设置为 INEGER.MAX_VALUE 解决了上述错误。 但我想知道为什么我只在一个实例中出现错误,为什么其他实例在更高负载下按预期工作。
任何人都可以分享max.poll.interval.ms 的正确根本原因和理想值或此问题的适当解决方案
【问题讨论】:
标签: java apache-kafka kafka-consumer-api spring-kafka