On this page
Kafka Improvement Proposal
KIP-455: an admin API for moving partitions
KIP-455 gave Kafka a proper API for moving partition replicas between brokers. Instead of writing a JSON plan into ZooKeeper, a tool asks the controller through the Admin API to reassign, list or cancel moves, and new moves can be added while others are still running. kafka-reassign-partitions.sh uses it.
- Proposal
- KIP-455, Create an Administrative API for Replica Reassignment
- Status
- Shipped API in Kafka 2.4 (2019); tool changes, including --cancel, in 2.5.
- Area
- Cluster and operations
- Proposal page
- KIP-455 on the Apache Kafka wiki
Why it was needed
Reassignment used to work by writing a znode in ZooKeeper that the controller watched. Only one batch of moves could run at a time, a running move could not be cancelled cleanly, and any tool doing it needed direct access to ZooKeeper, which got in the way of removing ZooKeeper altogether.
What it changes
The Admin API gained alterPartitionReassignments, to set a target replica list for a partition or cancel its move, and listPartitionReassignments, which shows the replicas being added and removed. The controller adds the new replicas, waits for them to join the ISR and then drops the old ones. Cancelling returns the partition to its original replicas.
How to use it
- Run kafka-reassign-partitions.sh --bootstrap-server with --generate, --execute and --verify; add --throttle to limit the bandwidth (KIP-73).
- Use --cancel to stop a running reassignment, and --additional to start more moves or change the throttle while one is running.
Where it stands
The API shipped in Kafka 2.4 and the tool changes in 2.5, which also deprecated the --zookeeper option. Since Kafka 4.0 the cluster runs only on KRaft and this API is the only way to reassign.
What comes next
Stable. Kafka 4.3 added cordoning of brokers and log directories (KIP-1066), which keeps new replicas off a broker you are about to drain.
See it in the simulator
- kafka-reassign-partitions: change a replica set by hand (Partition reassignment by hand) Step 3: Reassign - leader dropped, new replica outside the ISR Open at this step: kafka-reassign-partitions: change a replica set by hand
- Kafka partition reassignment: execute, throttle, verify (Move a partition: execute, throttle, verify) Step 5: Verified, and the throttle comes off with it Open at this step: Kafka partition reassignment: execute, throttle, verify
- Add a Kafka broker and reassign partitions onto it (Scale out + rebalance) Step 4: Partition 0 reassigning Open at this step: Add a Kafka broker and reassign partitions onto it