Bird
0
0

You want to ensure messages with the same user ID always go to the same partition, but messages without user ID keys should be evenly distributed. Which partitioner behavior should you rely on?

hard📝 Application Q15 of 15
Kafka - Producers

You want to ensure messages with the same user ID always go to the same partition, but messages without user ID keys should be evenly distributed. Which partitioner behavior should you rely on?

ADefault partitioner: keyed messages to same partition, unkeyed round-robin
BCustom partitioner that ignores keys and uses random partition
CRound-robin partitioner for all messages
DPartitioner that sends all messages to partition 0
Step-by-Step Solution
Solution:
  1. Step 1: Understand keyed message behavior

    Default partitioner sends messages with the same key to the same partition.
  2. Step 2: Understand unkeyed message behavior

    Messages without keys are distributed evenly using round-robin by default partitioner.
  3. Step 3: Match behavior to requirement

    Default partitioner: keyed messages to same partition, unkeyed round-robin matches the requirement exactly.
  4. Final Answer:

    Default partitioner: keyed messages to same partition, unkeyed round-robin -> Option A
  5. Quick Check:

    Default partitioner fits keyed + unkeyed needs [OK]
Quick Trick: Default partitioner handles keyed and unkeyed well [OK]
Common Mistakes:
  • Choosing custom partitioner ignoring keys
  • Using round-robin for keyed messages
  • Sending all messages to one partition

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes