0
0
Kafkadevops~20 mins

Log compaction in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Log Compaction Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of the Kafka log compaction status check?
Given the following Kafka topic configuration and status check command, what will be the output?
Kafka
kafka-topics.sh --describe --topic user-updates --bootstrap-server localhost:9092

Topic: user-updates	PartitionCount: 3	ReplicationFactor: 2	Configs: cleanup.policy=compact
Topic: user-updates	Partition: 0	Leader: 1	Replicas: 1,2	Isr: 1,2
Topic: user-updates	Partition: 1	Leader: 2	Replicas: 2,3	Isr: 2,3
Topic: user-updates	Partition: 2	Leader: 3	Replicas: 3,1	Isr: 3,1
AThe topic 'user-updates' has log compaction enabled with 3 partitions and replication factor 2.
BThe topic 'user-updates' has log compaction disabled and 3 partitions.
CThe topic 'user-updates' has 1 partition with log compaction enabled.
DThe topic 'user-updates' has 3 partitions but replication factor is 1.
Attempts:
2 left
💡 Hint
Look for the cleanup.policy configuration in the topic description.
🧠 Conceptual
intermediate
1:30remaining
What does Kafka log compaction guarantee?
Choose the correct statement about Kafka log compaction guarantees.
ALog compaction guarantees message order across all partitions.
BLog compaction guarantees that the latest value for each key is retained in the topic.
CLog compaction compresses messages to reduce disk usage without deleting any data.
DLog compaction deletes all messages older than a configured time.
Attempts:
2 left
💡 Hint
Think about what happens to messages with the same key after compaction.
Predict Output
advanced
1:30remaining
What error occurs when enabling log compaction with invalid cleanup.policy?
What error will Kafka produce if you set cleanup.policy=compacted instead of compact for a topic?
Kafka
kafka-topics.sh --create --topic test-topic --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1 --config cleanup.policy=compacted
AError: Replication factor must be greater than 1 for compaction
BTopic created successfully with log compaction enabled
CWarning: Unknown cleanup.policy value, defaulting to delete
DError: Invalid value 'compacted' for configuration 'cleanup.policy'
Attempts:
2 left
💡 Hint
Check the exact allowed values for cleanup.policy.
🚀 Application
advanced
1:30remaining
How to configure a topic for both log compaction and time-based deletion?
Which configuration correctly enables both log compaction and time-based deletion on a Kafka topic?
Acleanup.policy=compact delete
Bcleanup.policy=compact;delete
Ccleanup.policy=compact,delete
Dcleanup.policy=compact|delete
Attempts:
2 left
💡 Hint
Multiple policies are comma-separated in Kafka configs.
🧠 Conceptual
expert
2:00remaining
Why might Kafka log compaction not immediately remove old records?
Select the best explanation why Kafka log compaction does not instantly delete old records after a new record with the same key is written.
ACompaction runs periodically and only removes older duplicates during background cleanup, not immediately.
BKafka keeps all records forever regardless of compaction settings.
CCompaction requires manual trigger to delete old records.
DOld records are deleted immediately but only after consumer acknowledges.
Attempts:
2 left
💡 Hint
Think about how Kafka manages background tasks.