为什么 kafka 无法提交特定分区的偏移量?

Ank*_*ana 6 apache-kafka

kafka 消费者无法仅提交特定分区的偏移量。

aklsfoipafasldmaknfa    asiofuasofiusaofasd
[2019-01-04 12:22:22,691] ERROR [Consumer clientId=consumer-1, groupId=console-consumer-11955] Offset commit failed on partition my-topic-2-9 at offset 0: The request timed out. (org.apache.kafka.clients.consumer.internals.ConsumerCoordinator)
[2019-01-04 12:22:28,617] ERROR [Consumer clientId=consumer-1, groupId=console-consumer-11955] Offset commit failed on partition my-topic-2-9 at offset 1: The request timed out. (org.apache.kafka.clients.consumer.internals.ConsumerCoordinator)
as;lkasl;dkas;faskfasfasfasodaspd   qdoiwudqouoaisdiaduasodiuasd
[2019-01-04 12:23:18,875] ERROR [Consumer clientId=consumer-1, groupId=console-consumer-11955] Offset commit failed on partition my-topic-2-9 at offset 1: The request timed out. (org.apache.kafka.clients.consumer.internals.ConsumerCoordinator)
Run Code Online (Sandbox Code Playgroud)

谁能向我解释这个错误以及可能导致此错误的原因是什么?

我们的集群有 5 个代理在 AWS 中运行。我们使用 Apache Kafka 2.1。

我正在运行一个非常简单的 Kafka 控制台生产者,并使用 Kafka 控制台消费者消费相同的消息。

我在控制台消费者使用该消息后看到此错误。

// PRODUCER
./bin/kafka-console-producer.sh   --broker-list kafka1:9092   --topic my-topic-2 --property "parse.key=true"   --property "key.separator=,"

 //CONSUMER
./bin/kafka-console-consumer.sh --bootstrap-server kafka1:9092 --from-beginning --topic my-topic-2 --property="print.key=true"
Run Code Online (Sandbox Code Playgroud)

请注意,我们的集群有 200 多个主题,涉及许多生产者和消费者。

只是我无法理解这种行为。

他是grafana的截图。 在此输入图像描述

编辑:

请随时询问更多详细信息。这个错误确实令人沮丧。

编辑2:

./bin/kafka-topics.sh --describe --zookeeper zookeeper1:2181/kafka --topic my-topic-2
Topic:my-topic-2    PartitionCount:10   ReplicationFactor:3 Configs:
Topic: my-topic-2   Partition: 0    Leader: 4   Replicas: 4,2,3 Isr: 4,2,3
Topic: my-topic-2   Partition: 1    Leader: 5   Replicas: 5,3,4 Isr: 5,4,3
Topic: my-topic-2   Partition: 2    Leader: 1   Replicas: 1,4,5 Isr: 1,4,5
Topic: my-topic-2   Partition: 3    Leader: 2   Replicas: 2,5,1 Isr: 2,1,5
Topic: my-topic-2   Partition: 4    Leader: 3   Replicas: 3,1,2 Isr: 3,2,1
Topic: my-topic-2   Partition: 5    Leader: 4   Replicas: 4,3,5 Isr: 4,3,5
Topic: my-topic-2   Partition: 6    Leader: 5   Replicas: 5,4,1 Isr: 5,4,1
Topic: my-topic-2   Partition: 7    Leader: 1   Replicas: 1,5,2 Isr: 1,2,5
Topic: my-topic-2   Partition: 8    Leader: 2   Replicas: 2,1,3 Isr: 2,3,1
Topic: my-topic-2   Partition: 9    Leader: 3   Replicas: 3,2,4 Isr: 3,2,4
Run Code Online (Sandbox Code Playgroud)

编辑3:

我更感兴趣的是了解此问题的可能原因,这可能有助于我们找出集群的其他问题。

编辑4:

所有经纪人、消费者和生产者都位于同一区域的同一 VPC 中。
我知道可以增加偏移提交超时,但为什么呢?是什么导致了这样的延迟?对于一个应该是实时的系统来说,5000 毫秒本身就太多了。
有可能是kafka Broker超载或者网络拥塞,但是为什么呢?正如您所看到的,数据输入速率最大为 2-3 mbps,对于 5 台机器的 kafka 集群(r5.xlarge)来说是否太多了?告诉我是否是这样,我对卡夫卡很陌生。
在这样的设置中什么会成为瓶颈?

小智 4

您的消费者线程与主题分区之间的比率是多少?

我发现在我的集群中,当少量消费者线程从大量分区消费时(例如 1 个线程分配给 30 个主题分区),更有可能发生此错误。

对我来说,使这个错误消失的最佳配置是 1:1(每个主题分区有 1 个消费者线程),但现在当我想要向组添加更多消费者线程时,我遇到了缩放问题。

我通过开发一种消费者部署机制来处理这个问题,该机制强制执行 1:1 的比例,例如,当部署 3 个消费者来消费 30 个分区时,每个消费者将打开 10 个线程,而为了扩展,假设部署 10 个消费者,每个消费者将打开 3 个线程。 ..

我不知道我是否遵循了这里的最佳实践,但它现在可以完成工作