Challenge - 5 Problems
Kafka Retention Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What is the effect of this retention.ms setting?
Given a Kafka topic configured with
retention.ms=60000, what happens to messages older than 60 seconds?Kafka
kafka-topics.sh --alter --topic example-topic --config retention.ms=60000 --bootstrap-server localhost:9092
Attempts:
2 left
💡 Hint
Think about what retention.ms controls in Kafka.
✗ Incorrect
The retention.ms setting controls how long Kafka retains messages before deleting them. Setting it to 60000 means messages older than 60 seconds are removed.
❓ Predict Output
intermediate1:30remaining
What happens with this retention.bytes setting?
A Kafka topic has
retention.bytes=1048576 (1 MB). What happens when the topic size exceeds 1 MB?Kafka
kafka-topics.sh --alter --topic example-topic --config retention.bytes=1048576 --bootstrap-server localhost:9092
Attempts:
2 left
💡 Hint
Consider what retention.bytes limits in Kafka.
✗ Incorrect
The retention.bytes setting limits the total size of the topic. When the size exceeds this limit, Kafka deletes the oldest messages to free space.
🧠 Conceptual
advanced2:00remaining
Which retention policy combination causes messages to be deleted earliest?
If a Kafka topic has
retention.ms=3600000 (1 hour) and retention.bytes=10485760 (10 MB), when are messages deleted?Attempts:
2 left
💡 Hint
Think about how Kafka applies retention.ms and retention.bytes together.
✗ Incorrect
Kafka deletes messages when either the time limit or size limit is reached, whichever happens first.
❓ Predict Output
advanced1:30remaining
What error occurs with this retention.ms value?
What happens if you set
retention.ms=-1000 for a Kafka topic?Kafka
kafka-topics.sh --alter --topic example-topic --config retention.ms=-1000 --bootstrap-server localhost:9092
Attempts:
2 left
💡 Hint
Consider valid ranges for retention.ms in Kafka.
✗ Incorrect
Kafka does not allow negative values for retention.ms and throws a configuration error.
🧠 Conceptual
expert2:30remaining
How does Kafka handle retention with log compaction enabled?
If a Kafka topic has both
retention.ms=86400000 (1 day) and log compaction enabled, what is the retention behavior?Attempts:
2 left
💡 Hint
Think about how log compaction and retention.ms work together.
✗ Incorrect
With log compaction, Kafka retains the latest record for each key indefinitely, but messages older than retention.ms without a newer key version are deleted.