How would you increase a live Kafka topic’s partition count while controlling processing and ordering risks?

Instruction: Describe the steps and considerations for altering partition count in an existing Kafka topic, ensuring minimal impact on production traffic.

Context: This question assesses the candidate's practical skills in managing Kafka at scale, specifically their ability to perform topic reconfigurations live.

Updated

Official answer

Kafka supports increasing an existing topic's partition count online. That does not guarantee uninterrupted processing or preserved key placement, and reducing the count in place is not normally supported.

First record the current count, replica placement, producer partitioners, consumer subscriptions and per-partition workload. Check capacity and explain why expansion addresses the bottleneck. A single hot ordered key will not automatically split across more partitions.

The current administrative path uses the broker bootstrap endpoint with kafka-topics.sh and its --alter, --topic and --partitions options, or the Admin createPartitions API. Use the deployed version's command help and a secured client configuration. Do not use the removed --zookeeper administration path for Kafka 4.x. The new count is the total desired count, not the number to add.

New partitions start without the old partitions' historical records. A hash-based key mapping may send later events for an existing key to a new partition while earlier events remain in the old one. If per-key order across the transition is required, coordinate a drain/cutover or migrate through a new topic with an explicit ordering protocol.

Consumers must discover the new partitions, and subscribing groups may rebalance. Verify that manually assigned consumers are updated deliberately. After expansion, inspect placement, leader/replica health, processing age, error rate and key skew. Prepare a forward-recovery or new-topic plan because shrinking back is not a simple rollback.

Topic partition administration, Admin API

Related Questions