kafka consumer lag 为负数

悪魔の呼び声 发表于: 2020-01-21   最后更新时间: 2020-01-21 14:01:25   9,088 游览

请问 kafka lag 为什么会出现负数的情况呢?

发表于 2020-01-21

Producer 的 offset 是通过 JMX 轮询获得的,Consumer 的 offset 是从 kafka 内的 __consumer_offsets 的 topic 中直接读取到的,很明显轮询获取 offset 比 直接从 topic 拿 offset 慢一点,也就可能会出现 Lag 计算后为负数的情况。

消息过期了(超过默认7天),已经被清理掉了,会出现这种情况。

kafkaManager官方的解释如下
Producer offset is polled. Consumer offset is read from the offset topic for Kafka based consumers. This means the reported lag may be negative since we are consuming offset from the offset topic faster then polling the producer offset. This is normal and not a problem.
附链接:https://github.com/yahoo/CMAK

你的答案

查看kafka相关的其他问题或提一个您自己的问题