Bird
0
0

Given a Kafka topic 'events' with 2 partitions, if a producer sends 4 messages without specifying a key, how are messages distributed?

medium📝 Predict Output Q4 of 15
Kafka - Basics and Event Streaming
Given a Kafka topic 'events' with 2 partitions, if a producer sends 4 messages without specifying a key, how are messages distributed?
AAll messages go to partition 1
BAll messages go to partition 0
CMessages are distributed evenly across the two partitions
DMessages are duplicated in both partitions
Step-by-Step Solution
Solution:
  1. Step 1: Understand default partitioning without key

    When no key is specified, Kafka uses round-robin to distribute messages evenly across partitions.
  2. Step 2: Apply to 4 messages and 2 partitions

    Messages 1 and 3 go to partition 0; messages 2 and 4 go to partition 1.
  3. Final Answer:

    Messages are distributed evenly across the two partitions -> Option C
  4. Quick Check:

    Messages without key = even partition distribution [OK]
Quick Trick: No key means round-robin distribution across partitions [OK]
Common Mistakes:
  • Assuming all messages go to one partition
  • Thinking messages duplicate across partitions
  • Confusing key-based routing with default

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes