Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will the messages get deleted even if it's not consumed in Kafka

Tags:

apache-kafka

In Kafka, will there be any situation such that the log retention policy is configured in a way that it will actually delete the messages even before the consumer can read that message?

like image 303
RSSAH Avatar asked Sep 01 '25 10:09

RSSAH


1 Answers

Yes that is possible.

Kafka does not track how many times each message is consumed. After a message has reached its retention limits (due to time or size), it will be eligible to deletion.

In practice, deletion only happens on segments so messages stay longer than the limits but you should not rely on that.

Note that consumers expose a records-lead metrics that indicates how far they are from the front (where messages are deleted) of the log. If you see this metric dropping over time, it is an indicator you may run into this scenario.

like image 87
Mickael Maison Avatar answered Sep 03 '25 23:09

Mickael Maison