How to fix negative consumer lag in Kafka
Codemia Knowledge Hub ·
Negative consumer lag means the consumer's current offset is ahead of the latest offset in the log. The usual fix is to confirm the real offsets with the Kafka CLI, check the topic's retention settings, and reset the consumer group's offsets if they are wrong.
What negative lag means
Consumer lag is the difference between the last message produced (the latest offset in the partition) and the last message consumed (the consumer's current offset). It normally tells you how far a consumer is behind. A negative value says the consumer is past the end of the log, which should not happen in a healthy setup.
Common causes
- Topic deletion or log compaction: if retention or deletion removes older messages, the producer side offset can reset or decrease.
- Offset resets: a consumer may have its offset moved to a newer value, either manually or through a configuration error.
- Topic or partition misconfiguration: wrong settings can make topic offsets decrease or be misreported.
- Monitoring tool errors: the tool showing the lag may calculate it wrongly because of bugs or stale data.
Step 1: Verify consumer and producer offsets
Check both offsets directly from Kafka:
Step 2: Review the topic configuration
Make sure retention policies and partition settings match what you expect:
Step 3: Reset the consumer group's offsets
If the consumer side is misconfigured, fix the group id or offset reset settings, or move the group's offsets explicitly:
Step 4: Keep monitoring
Watch lag with Kafka's own tools or with an external stack such as Prometheus and Grafana, and adjust configuration based on what you see.
Quick reference
| Issue Identified | Solution | Command/Action |
| Consumer Offset Ahead of Producer | Reset Consumer Offsets | kafka-consumer-groups --reset-offsets |
| Incorrect Topic Configuration | Review & Adjust Topic Settings | kafka-configs --describe |
| Fault in Monitoring Tools | Validate with CLI and Other Tools | Use CLI and cross-check with other monitoring tools |
Related reading
- How to get Spring RabbitMQ to create a new Queue?
- how to get the all messages in a topic from kafka server
- how to get the group commit offset from kafka(0.10.x)
- How to get the latest offset from the Kafka topic in Confluent kafka C# library?
- How to get topic list from kafka server in Java
- How to get topics list from Kafka using C#
- How to get windowed aggregation from kafka stream?
- How to gracefully shutdown spring-kafka consumer application
Course lessons on this
System design interview problems on this topic
- Design a Distributed Messaging System: solution and walkthrough
- Design a Log Collection and Analysis System: solution and walkthrough
- Design an Ad Click Aggregation System: solution and walkthrough
- Design a Webhook Notification Service: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.