Introduction
Log compaction in Kafka helps keep only the latest value for each key in a topic. This saves space and ensures consumers can always get the most recent update without reading the entire log.
When you want to keep a snapshot of the latest state for each key in a topic.
When you need to recover the current state quickly after a failure.
When you want to reduce storage by removing old records but keep the latest updates.
When you have a topic that stores user profiles or configurations that change over time.
When you want to ensure consumers can rebuild state from a compacted topic efficiently.