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:
- 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.
- Kafka hashes the key:
- Message has NO Key (
null):- Modern Kafka uses the Sticky Partitioner: it batches records destined for a single partition until
batch.sizeorlinger.msis reached, then rotates to another partition. This maximizes network batching efficiency while maintaining even load distribution across partitions.
- Modern Kafka uses the Sticky Partitioner: it batches records destined for a single partition until