什么是正常的卡夫卡偏移滞后?为什么最小值是1(不是0)?

时间:2015-10-02 08:08:16

标签: apache-kafka

我已经配置了3个Kafka经纪人:

/opt/kafka/bin/kafka-topics.sh --describe --topic logs --zookeeper=localhost:2181
Topic:logs  PartitionCount:8    ReplicationFactor:3 Configs:
    Topic: logs Partition: 0    Leader: 1   Replicas: 1,2,0 Isr: 0,1,2
    Topic: logs Partition: 1    Leader: 2   Replicas: 2,0,1 Isr: 0,1,2
    Topic: logs Partition: 2    Leader: 0   Replicas: 0,1,2 Isr: 0,1,2
    Topic: logs Partition: 3    Leader: 1   Replicas: 1,0,2 Isr: 0,1,2
    Topic: logs Partition: 4    Leader: 2   Replicas: 2,1,0 Isr: 0,1,2
    Topic: logs Partition: 5    Leader: 0   Replicas: 0,2,1 Isr: 0,1,2
    Topic: logs Partition: 6    Leader: 1   Replicas: 1,2,0 Isr: 0,1,2
    Topic: logs Partition: 7    Leader: 2   Replicas: 2,0,1 Isr: 0,1,2

我注意到所有时间最小偏移滞后值都是1.

/opt/kafka/bin/kafka-consumer-offset-checker.sh --group logreaders --topic logs --zookeeper=localhost:2181
Group           Topic                          Pid Offset          logSize         Lag             Owner
logreaders      logs                           0   255851          255852          1               none
logreaders      logs                           1   254514          254515          1               none
logreaders      logs                           2   252885          252888          3               none
logreaders      logs                           3   255904          255905          1               none
logreaders      logs                           4   253897          253898          1               none
logreaders      logs                           5   253517          253519          2               none
logreaders      logs                           6   255098          255099          1               none
logreaders      logs                           7   255412          255414          2               none

我预计最小偏移延迟应该是-0,所以我想弄清楚这是否正常。它看起来不像我正在丢失消息,但这让我感到困惑。

Kafka版本为0.8.2.1

1 个答案:

答案 0 :(得分:-2)

此问题与您的 KAFKA PERFORMANCE TUNING 有关。很明显,你的消费者无法赶上制片人 这可以通过调整消费者配置来实现。 Apache Kafka已就此提供了非常好的documentation,请参考并调整您的消费者。

如果您对消费者调整有任何疑问,请告诉我。