Skip to main content
InterviewHubPRO
Section Overview
Q4

Question 4 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

8%
Apache Kafka Streaming (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

What is a Producer, and how does message partitioning work (Keys vs. Round-Robin)?

junior LevelkafkaBasic

In Simple Words: A Producer publishes records to Kafka topics. How Kafka decides which partition receives a message:

  1. Message has a Key (e.g., userId: "usr_1001"):
    • Kafka hashes the key: MurmurHash2(key) % total_partitions.
    • Critical Guarantee: All messages with the same key will always go to the same partition, guaranteeing strict chronological ordering for that specific entity.
  2. Message has NO Key (null):
    • Modern Kafka uses the Sticky Partitioner: it batches records destined for a single partition until batch.size or linger.ms is reached, then rotates to another partition. This maximizes network batching efficiency while maintaining even load distribution across partitions.