📥Kafka Retention
Also known as Kafka Retention Period, Topic Retention, retention.ms
How long a Kafka topic keeps its events before it deletes them. The default is 7 days.
Think of it like
It is like a phone that wipes old messages after a week. It does not wait for you to hear them.
Example
A team keeps the clicks topic for 30 days. A new report can then read a full month of clicks from the start.
Why it matters
It decides how far back any reader can go. If it is too short, a broken reader loses data before it is fixed.
Definition
Example code
console
$ bin/kafka-configs.sh --bootstrap-server localhost:9092 --alter \
--entity-type topics --entity-name clicks \
--add-config retention.ms=2592000000Common mistake
Key takeaways
- 1Time or size. Delete by age or by bytes.
- 2Read or not. Old events go either way.
- 3Or compact. Keep only the latest per key.