A Kafka topic configuration is a set of settings that control how a topic behaves, such as retention time, number of partitions, and replication factor.
Click to reveal answer
beginner
What does the 'retention.ms' configuration control in a Kafka topic?
The 'retention.ms' setting controls how long Kafka keeps the messages in a topic before deleting them, measured in milliseconds.
Click to reveal answer
beginner
How does the 'partitions' setting affect a Kafka topic?
The 'partitions' setting defines how many parts a topic is split into, allowing parallel processing and scalability.
Click to reveal answer
intermediate
What is the role of 'replication.factor' in Kafka topic configuration?
The 'replication.factor' determines how many copies of each partition are kept across different brokers for fault tolerance.
Click to reveal answer
intermediate
How can you change a Kafka topic's configuration after it is created?
You can use Kafka's command-line tools or APIs to alter topic configurations like retention time or cleanup policy without deleting the topic.
Click to reveal answer
Which configuration controls how long messages are stored in a Kafka topic?
Apartitions
Bcleanup.policy
Creplication.factor
Dretention.ms
✗ Incorrect
The 'retention.ms' setting controls the message retention time in milliseconds.
What does increasing the number of partitions in a topic do?
AIncreases replication factor
BDecreases message retention time
CIncreases parallelism and throughput
DChanges the topic name
✗ Incorrect
More partitions allow more consumers to read in parallel, improving throughput.
What is the default replication factor if not set explicitly?
A2
B1
C3
D0
✗ Incorrect
By default, Kafka sets replication factor to 1, meaning no replication.
Which tool can be used to change topic configuration after creation?
Akafka-configs.sh
Bkafka-topics.sh
Ckafka-console-producer.sh
Dkafka-console-consumer.sh
✗ Incorrect
'kafka-configs.sh' is used to alter topic configurations.
What does the 'cleanup.policy' configuration control?
AHow messages are deleted or compacted
BNumber of partitions
CReplication factor
DMessage format
✗ Incorrect
'cleanup.policy' defines whether messages are deleted or compacted.
Explain the key configurations you can set for a Kafka topic and their effects.
Think about message storage time, parallelism, fault tolerance, and message deletion.
You got /4 concepts.
How can you update a Kafka topic's configuration after it has been created? Describe the process.
Focus on tools and commands used to change settings safely.
You got /4 concepts.
Practice
(1/5)
1. What does the retention.ms configuration control in a Kafka topic?
easy
A. How long messages are kept before deletion
B. The number of partitions in the topic
C. The replication factor of the topic
D. The maximum message size allowed
Solution
Step 1: Understand retention.ms meaning
The retention.ms setting defines the time in milliseconds that Kafka retains messages before deleting them.
Step 2: Compare with other options
Other options like partitions, replication factor, and message size are controlled by different configurations.
Final Answer:
How long messages are kept before deletion -> Option A
Quick Check:
retention.ms = message retention time [OK]
Hint: Retention means how long messages stay before removal [OK]
Common Mistakes:
Confusing retention.ms with replication factor
Thinking retention.ms controls partition count
Assuming retention.ms limits message size
2. Which of the following is the correct syntax to create a Kafka topic with a replication factor of 3 using the command line?
D. kafka-topics.sh --create --topic myTopic --replication-factor=3 --partitions 1 --bootstrap-server localhost:9092
Solution
Step 1: Identify correct option name
The correct option for replication factor is --replication-factor without equals sign.
Step 2: Check syntax correctness
kafka-topics.sh --create --topic myTopic --replication-factor 3 --partitions 1 --bootstrap-server localhost:9092 uses the correct syntax with spaces and proper option names; others have wrong option names or equals sign which is invalid here.
Use --replication-factor with space, no equals [OK]
Hint: Use --replication-factor with space, no equals sign [OK]
Common Mistakes:
Using --replication instead of --replication-factor
Adding equals sign (=) after option name
Misspelling replication-factor option
3. Given the command: kafka-topics.sh --alter --topic logs --config retention.ms=60000 --bootstrap-server localhost:9092 What will be the effect on the topic logs?
medium
A. Messages will be retained indefinitely
B. The topic's replication factor will be set to 60000
C. The topic will be deleted after 60000 messages
D. Messages will be retained for 1 minute before deletion
Solution
Step 1: Understand the command's purpose
The command alters the topic logs by setting retention.ms to 60000 milliseconds (1 minute).
Step 2: Interpret retention.ms effect
This means messages older than 1 minute will be deleted automatically.
Final Answer:
Messages will be retained for 1 minute before deletion -> Option D
Quick Check:
retention.ms=60000 means 1 minute retention [OK]
Hint: retention.ms value is in milliseconds for message lifetime [OK]
Common Mistakes:
Thinking retention.ms controls message count
Confusing retention.ms with replication factor
Assuming retention.ms disables deletion
4. You tried to set the cleanup policy of a Kafka topic with: kafka-topics.sh --alter --topic data --config cleanup.policy=delete,compact --bootstrap-server localhost:9092 But it failed. What is the likely cause?
medium
A. The --alter command cannot change cleanup.policy
B. The cleanup.policy value is invalid; it must be either 'delete' or 'compact', not both
C. The topic name 'data' is reserved and cannot be altered
D. The bootstrap server address is incorrect
Solution
Step 1: Check cleanup.policy valid values
Kafka allows cleanup.policy to be either 'delete' or 'compact' or both separated by comma, but the syntax must be exact and supported by the Kafka version.
Step 2: Identify common error
Some Kafka versions or setups do not support combined policies or require no spaces; if the command failed, likely the value was invalid or syntax incorrect.
Final Answer:
The cleanup.policy value is invalid; it must be either 'delete' or 'compact', not both -> Option B
Quick Check:
cleanup.policy must be valid single or combined value [OK]
Hint: Check cleanup.policy values carefully; some setups disallow combined [OK]
Common Mistakes:
Using unsupported combined cleanup policies
Trying to alter topic with wrong bootstrap server
Assuming topic names cannot be altered
5. You want to create a Kafka topic named events with 4 partitions, replication factor 2, and a retention time of 2 hours. Which command correctly sets all these configurations?