Does increasing the number of partitions affect the guarantee that all messages with the same key go 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 increasing the number of partitions affect the guarantee that all messages with the same key go to the same partition?

Explanation:
Partitioning in Kafka uses a hash of the key modulo the number of partitions to decide the target partition. When you increase the number of partitions, the modulo base changes, so the partition chosen for a given key can change. As a result, messages with the same key sent after the change may land in a different partition than earlier messages with that key. The guarantee holds only while the partition count stays fixed; once you add partitions, that cross-time guarantee is no longer preserved, though within a single fixed set of partitions the mapping remains deterministic and the same key will always go to the same partition.

Partitioning in Kafka uses a hash of the key modulo the number of partitions to decide the target partition. When you increase the number of partitions, the modulo base changes, so the partition chosen for a given key can change. As a result, messages with the same key sent after the change may land in a different partition than earlier messages with that key. The guarantee holds only while the partition count stays fixed; once you add partitions, that cross-time guarantee is no longer preserved, though within a single fixed set of partitions the mapping remains deterministic and the same key will always go to the same partition.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy