From the course: Complete Guide to Apache Kafka for Beginners

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Producer default partitioner and sticky partitioner

Producer default partitioner and sticky partitioner - Kafka Tutorial

From the course: Complete Guide to Apache Kafka for Beginners

Producer default partitioner and sticky partitioner

Okay. So let's go over one last thing, which is the default partitioner for your producer. So when your key is not null, then your data is going to go through a partitioner logic which decides how a record gets assigned to a partition. And this process is called key hashing, which is the process of determining the mapping of a key to a partition. And in the default Kafka partitioner the key are hashed using the murmur2 algorithm and this is the formula. And if we look at this formula, we can see that the same key goes to the same partition, because the murmur algorithm, it's predictable and therefore the same key goes to the same partition, because the formula has the exact same inputs and the exact same formula. But if we look at the formula, we look at the fact that if you look at num partitions, which is the right hand side part of this formula, and we increase it because we add partitions into our topic, then this entire formula is affected. And therefore once you add partitions…

Contents