Bird
0
0

Why does Kafka's default partitioner use the hash of the key instead of just assigning partitions in a round-robin manner?

hard📝 Conceptual Q10 of 15
Kafka - Producers

Why does Kafka's default partitioner use the hash of the key instead of just assigning partitions in a round-robin manner?

ATo ensure messages with the same key go to the same partition for ordering
BTo improve compression efficiency
CTo reduce network bandwidth usage
DTo balance load evenly regardless of key
Step-by-Step Solution
Solution:
  1. Step 1: Understand message ordering in Kafka

    Kafka guarantees order only within a partition, so messages with the same key must go to the same partition.
  2. Step 2: Role of hashing key

    Hashing the key ensures consistent partition assignment for the same key, preserving order.
  3. Final Answer:

    To ensure messages with the same key go to the same partition for ordering -> Option A
  4. Quick Check:

    Key hashing preserves message order per key [OK]
Quick Trick: Hash key to keep message order per partition [OK]
Common Mistakes:
  • Thinking hashing improves compression
  • Assuming hashing reduces bandwidth
  • Believing round-robin balances load better for keys

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes