0
0
Kafkadevops~10 mins

Log compaction in Kafka - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the topic cleanup policy to log compaction.

Kafka
props.put("cleanup.policy", "[1]");
Drag options to blanks, or click blank then click option'
Acompact
Bdelete
Cnone
Darchive
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'delete' instead of 'compact' disables log compaction.
Misspelling the cleanup policy value.
2fill in blank
medium

Complete the code to create a compacted topic named 'user-updates'.

Kafka
bin/kafka-topics.sh --create --topic user-updates --partitions 3 --replication-factor 1 --config cleanup.policy=[1] --bootstrap-server localhost:9092
Drag options to blanks, or click blank then click option'
Acompact
Bdelete
Carchive
Dnone
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'delete' which enables time-based deletion instead of compaction.
Omitting the cleanup.policy config.
3fill in blank
hard

Fix the error in the code to configure log compaction for an existing topic.

Kafka
bin/kafka-configs.sh --alter --entity-type topics --entity-name user-logs --add-config cleanup.policy=[1] --bootstrap-server localhost:9092
Drag options to blanks, or click blank then click option'
Adelete
Barchive
Ccompact
Dnone
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'delete' which disables compaction.
Using an invalid cleanup policy value.
4fill in blank
hard

Fill both blanks to create a compacted topic with 4 partitions and replication factor 2.

Kafka
bin/kafka-topics.sh --create --topic logs --partitions [1] --replication-factor [2] --config cleanup.policy=compact --bootstrap-server localhost:9092
Drag options to blanks, or click blank then click option'
A4
B2
C3
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using replication factor 1 which reduces fault tolerance.
Using fewer partitions than required.
5fill in blank
hard

Fill all three blanks to configure a producer to enable idempotence and set retries to 5.

Kafka
props.put("enable.idempotence", [1]);
props.put("acks", "[2]");
props.put("retries", [3]);
Drag options to blanks, or click blank then click option'
Afalse
Ball
C5
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Setting enable.idempotence to false disables safe retries.
Using acks other than 'all' reduces delivery guarantees.
Setting retries to 0 disables retry attempts.