Bird
0
0

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?

hard📝 Application Q15 of 15
Kafka - Topics and Partitions
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?
Akafka-topics.sh --create --topic events --partitions 4 --replication-factor 2 --config retention.ms=120 --bootstrap-server localhost:9092
Bkafka-topics.sh --create --topic events --partitions 2 --replication-factor 4 --config retention.ms=7200000 --bootstrap-server localhost:9092
Ckafka-topics.sh --create --topic events --partitions 4 --replication-factor 2 --config retention.ms=7200000 --bootstrap-server localhost:9092
Dkafka-topics.sh --create --topic events --partitions 4 --replication-factor 2 --config retention.ms=7200 --bootstrap-server localhost:9092
Step-by-Step Solution
Solution:
  1. Step 1: Verify partitions and replication factor

    The topic requires 4 partitions and replication factor 2, so options with these exact values are correct.
  2. Step 2: Calculate retention.ms for 2 hours

    2 hours = 2 * 60 * 60 * 1000 = 7,200,000 milliseconds. Only kafka-topics.sh --create --topic events --partitions 4 --replication-factor 2 --config retention.ms=7200000 --bootstrap-server localhost:9092 uses this correct retention.ms value.
  3. Final Answer:

    kafka-topics.sh --create --topic events --partitions 4 --replication-factor 2 --config retention.ms=7200000 --bootstrap-server localhost:9092 -> Option C
  4. Quick Check:

    Retention in ms for 2 hours = 7200000 [OK]
Quick Trick: Convert hours to ms: hours * 3600000 for retention.ms [OK]
Common Mistakes:
  • Mixing partitions and replication factor values
  • Using retention.ms in seconds or minutes instead of ms
  • Incorrect retention.ms calculation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes