kafka消费报错
問題描述:
 新版本的kafka消息處理程序中,當消息量特別大時不斷出現如下錯誤,并且多個相同groupId的消費者重復消費消息。
2018-10-12 19:49:34,903 WARN [DESKTOP-8S2E5H7 id2-1-C-1] Caller+0 at org.apache.kafka.clients.consumer.internals.ConsumerCoordinator$4.onComplete(ConsumerCoordinator.java:649)
 Auto-commit of offsets {xxxTopic-5=OffsetAndMetadata{offset=359, metadata=’’}} failed for group My-Group-Name: 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.
解決辦法:
 分析:
 1, 根據問題描述,處理消息的時間太長,優化消息處理(整個消息的處理時間有所減少),該告警有所減少,但是依然存在。
 2,根據問題描述,將max.poll.records值設置為200(默認值是500),并增加了session timeout(session.timeout.ms=60000, 默認值是5000,也就是5s),檢測日志,問題有所改善,但是依然存在。
至于消息被重復消費,這是因為發送大量消息(group.id=abc)時,consumer1消息處理時間太長,而consumer設置的是自動提交,因為不能在默認的自動提交時間內處理完畢,所以自動提交失敗,導致kafka認為該消息沒有消費成功,因此consumer2(group.id=abc,同一個group.id的多個消費實例)又獲得該消息開始重新消費。可以通過查看kafka中該topic對應的group的lag來驗證。
最終決絕辦法,增加auto.commit.interval.ms , 默認值是5000,增加到7000之后,同等kafka消息量下,基本沒有了該告警消息。
 為什么修改該參數,因為該告警的本質原因是, 消息處理時間過長,不能在設置的自動提交間隔時間內完成消息確認提交。
 ?
總結
 
                            
                        - 上一篇: skywalking告警相关配置
- 下一篇: go 安装墙外的依赖包报错问题
