0
0
Kafkadevops~5 mins

Log compaction in Kafka - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is log compaction in Kafka?
Log compaction is a Kafka feature that retains only the latest value for each key in a topic, removing older duplicates to save storage and ensure data freshness.
Click to reveal answer
beginner
How does Kafka decide which messages to keep during log compaction?
Kafka keeps the latest message for each unique key and removes older messages with the same key during log compaction.
Click to reveal answer
intermediate
What is the difference between log compaction and log retention by time?
Log retention by time deletes messages older than a set time, while log compaction keeps the latest message per key regardless of age.
Click to reveal answer
intermediate
Why is log compaction useful in Kafka?
It helps keep topics small by removing outdated data, supports stateful stream processing, and ensures consumers can recover the latest state efficiently.
Click to reveal answer
advanced
What happens if a message with a key is sent with a null value in a compacted topic?
A message with a null value acts as a delete marker (tombstone) for that key, so the key and its data are removed during compaction.
Click to reveal answer
What does Kafka's log compaction keep for each key?
AThe latest message only
BAll messages regardless of key
COnly messages older than a set time
DMessages with null values only
What is the purpose of a tombstone message in a compacted topic?
ATo add a new key
BTo mark a key for deletion
CTo duplicate a message
DTo reset the topic
Which scenario best fits using log compaction?
AArchiving logs to cold storage
BStoring all sensor readings forever
CDeleting messages after 7 days
DKeeping the latest user profile updates
How does log compaction affect topic size?
AIt increases size by adding more messages
BIt has no effect on size
CIt reduces size by removing old duplicates
DIt deletes all messages periodically
Can log compaction remove messages with unique keys that have never been duplicated?
AYes, if the message value is null
BYes, it removes all messages older than a threshold
CNo, it keeps the latest message for each key
DNo, it removes only messages with duplicate keys
Explain how Kafka's log compaction works and why it is useful.
Think about how Kafka keeps only the freshest data for each key.
You got /4 concepts.
    Describe the role of tombstone messages in log compaction.
    Consider how Kafka deletes keys using special messages.
    You got /4 concepts.