Kafka: You can add partitions but never remove them

And adding them changes where keys land, so ordering across the change is lost.

Code
kafka-topics.sh --bootstrap-server localhost:9092 \
  --alter --topic orders --partitions 12
Output
order-42 was on partition 3 with 6 partitions.
With 12 it maps to partition 9 - and the old events stay on 3.

Two partitions now hold the history of one key, in the wrong order.
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-11