Kafka控制台消费者错误“分区上的偏移提交失败”

时间:2018-05-02 13:15:19

标签: apache-kafka kafka-consumer-api

我使用kafka-console-consumer来探测kafka主题。

间歇性地,我收到此错误消息,然后是2个警告:

[2018-05-01 18:14:38,888] ERROR [Consumer clientId=consumer-1, groupId=console-consumer-56648] Offset commit failed on partition my-topic-0 at offset 444: The coordinator is not aware of this member. (org.apache.kafka.clients.consumer.internals.ConsumerCoordinator)

[2018-05-01 18:14:38,888] WARN [Consumer clientId=consumer-1, groupId=console-consumer-56648] Asynchronous auto-commit of offsets {my-topic-0=OffsetAndMetadata{offset=444, metadata=''}} failed: 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.internals.ConsumerCoordinator)

[2018-05-01 18:14:38,888] WARN [Consumer clientId=consumer-1, groupId=console-consumer-56648] Synchronous auto-commit of offsets {my-topic-0=OffsetAndMetadata{offset=447, metadata=''}} failed: 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.internals.ConsumerCoordinator)

它在警告日志中建议:

  

这意味着后续调用poll()的时间长于配置的max.poll.interval.ms,这通常意味着轮询循环花费了太多时间进行消息处理。您可以通过增加会话超时或通过max.poll.records减少poll()中返回的批量的最大大小来解决此问题。

因此,我需要增加max.poll.interval.ms或减少max.poll.records

请告知每种方法的含义,以及哪种方法在不同的情况下首选?

1 个答案:

答案 0 :(得分:8)

如果您增加max.poll.interval.ms则表示“花时间处理大量记录是可以的”,并且如果您能比较小的记录更有效地处理较大的记录,您将获得吞吐量。

要减少max.poll.records,请说“减少记录,以便有足够的时间来处理它们”,并宁愿延迟而不是吞吐量。

还要考虑两者都配置良好,但是其他原因也会导致poll循环内的性能问题。在更改配置之前,我将先进行探讨,以免掩盖更大的问题。

相关问题