Does adding a partition to a topic lose the guarantee that the same key goes to the same partition?

Study for the CCDAK Apache Kafka Test. Use flashcards and multiple choice questions with hints and explanations for each question. Prepare thoroughly for your exam!

Multiple Choice

Does adding a partition to a topic lose the guarantee that the same key goes to the same partition?

Explanation:
The mapping of a key to a partition is based on the number of partitions for the topic. Kafka’s default partitioner hashes the key and uses that hash modulo the current number of partitions to pick a partition. If you add more partitions, the modulo base changes, so the same key can end up in a different partition for new messages. In other words, the guarantee that a given key always lands on the same partition holds only while the partition count stays the same; increasing partitions can change where that key goes. Old messages remain in their original partitions, but future ones may be routed elsewhere.

The mapping of a key to a partition is based on the number of partitions for the topic. Kafka’s default partitioner hashes the key and uses that hash modulo the current number of partitions to pick a partition. If you add more partitions, the modulo base changes, so the same key can end up in a different partition for new messages. In other words, the guarantee that a given key always lands on the same partition holds only while the partition count stays the same; increasing partitions can change where that key goes. Old messages remain in their original partitions, but future ones may be routed elsewhere.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy