Adding a partition in Kafka

The impact is pretty clear. Below we load ten events using a given key. We add a partition, then load ten more events. Notice the partition differs after adding a partition, even though the key is the same.

Steve-Howards-MBP13:confluent-5.1.2 steve.howard$ for i in {1..10}; do java ProducerDemo 2>/dev/null | grep Partition; done | sort | uniq -c
  10 Partition:1
Steve-Howards-MBP13:bin steve.howard$ ./kafka-topics --zookeeper localhost:2181 --topic bar --alter --partitions 4
WARNING: If partitions are increased for a topic that has a key, the partition logic or ordering of the messages will be affected
Adding partitions succeeded!
Steve-Howards-MBP13:confluent-5.1.2 steve.howard$ for i in {1..10}; do java ProducerDemo 2>/dev/null | grep Partition; done | sort | uniq -c
  10 Partition:0
Steve-Howards-MBP13:confluent-5.1.2 steve.howard$ 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.