0
0
Kafkadevops~20 mins

Topic creation in Kafka - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Kafka Topic 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 this Kafka topic creation command?
Consider the following Kafka CLI command to create a topic named orders with 3 partitions and a replication factor of 2. What will be the output if the command runs successfully?
Kafka
kafka-topics.sh --create --topic orders --partitions 3 --replication-factor 2 --bootstrap-server localhost:9092
ANo output, command runs silently.
BCreated topic orders.
CWarning: Replication factor larger than available brokers.
DError: Topic orders already exists.
Attempts:
2 left
💡 Hint
Think about what the Kafka CLI prints when a topic is created successfully.
🧠 Conceptual
intermediate
1:30remaining
Which property defines the number of partitions when creating a Kafka topic?
When creating a Kafka topic, which configuration property controls how many partitions the topic will have?
Atopic.partitions
Breplication.factor
Cpartition.count
Dnum.partitions
Attempts:
2 left
💡 Hint
Look for the property name that clearly relates to partitions count.
Predict Output
advanced
2:00remaining
What error does this Kafka topic creation command produce?
What error message will this command produce if there is only 1 broker running but the replication factor is set to 3?
Kafka
kafka-topics.sh --create --topic logs --partitions 2 --replication-factor 3 --bootstrap-server localhost:9092
AError: Replication factor: 3 larger than available brokers: 1
BError: Topic logs already exists.
CCreated topic logs.
DWarning: Partitions count less than replication factor.
Attempts:
2 left
💡 Hint
Replication factor cannot be larger than the number of brokers.
🚀 Application
advanced
1:30remaining
How many partitions will the topic have after this command?
You run this command to create a topic without specifying partitions. The Kafka broker's default number of partitions is set to 4. How many partitions will the new topic have?
Kafka
kafka-topics.sh --create --topic payments --replication-factor 1 --bootstrap-server localhost:9092
A4
B1
C0
DDepends on the client configuration
Attempts:
2 left
💡 Hint
If partitions are not specified, Kafka uses the broker default.
🔧 Debug
expert
2:30remaining
Why does this topic creation command fail with a syntax error?
Identify the syntax error in this Kafka topic creation command and explain why it fails.
Kafka
kafka-topics.sh --create --topic "user-activity" --partitions 3 --replication-factor 1 --bootstrap-server localhost:9092
APartitions must be specified after bootstrap-server.
BReplication factor must be greater than 1.
CMissing closing quote after topic name causes syntax error.
DTopic name cannot contain hyphens.
Attempts:
2 left
💡 Hint
Check the quotes around the topic name carefully.