Status
Current state: Draft
Discussion thread: TBD
JIRA: TBD
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Motivation
When creating topics or partitions, the Kafka controller has to pick brokers to host the new partitions. The current placement logic is based on a round robin algorithm and supports rack awareness. This works well in most cases, but it does not take into account any operations planned, in progress, or recently completed on the cluster.
For example if we have a 3 broker cluster that is at capacity and add 3 new brokers, the placement logic will assign partitions on all 6 brokers. Ideally we’d like new partitions to be placed in priority on the new brokers.
Another issue happens if we want to scale down a cluster. Before decommissioning a broker an operator reassigns its partitions onto other brokers. But if new partitions are created, there isn’t a mechanism to prevent Kafka from placing them on that broker. In clusters with frequent topic creations, this makes the process of decommissioning brokers painful.
Similar scenarios happen when scaling storage in JBOD environments. Unlike the partition assignment, the selection of the log directory to use to host a new partition does not use round robin but instead the directory with the least amount of partitions is picked. If the disk sizes are not homogenous, or if some partitions are much larger than others, this forces operators to regularly shuffle partitions between log directories. This also makes the process of removing a disk painful as removing partitions makes the log directory more likely to host any new partitions being created.
This KIP aims at improving the following scenarios:
- When adding brokers to a cluster, Kafka currently does not always place new partitions on new brokers
- When removing brokers/log directories, there is no way to prevent Kafka from placing new replicas on these brokers/log directories
It will also serve as a basis for the decommissioning brokers process. For that operation our documentation states that “we plan to add tooling support for decommissioning brokers in the future.” since 2015.
Public Interfaces
Briefly list any new interfaces that will be introduced as part of this proposal or any existing interfaces that will be removed or changed. The purpose of this section is to concisely call out the public contract that will come along with this feature.
A public interface is any change to the following:
Binary log format
The network protocol and api behavior
Any class in the public packages under clientsConfiguration, especially client configuration
org/apache/kafka/common/serialization
org/apache/kafka/common
org/apache/kafka/common/errors
org/apache/kafka/clients/producer
org/apache/kafka/clients/consumer (eventually, once stable)
Monitoring
Command line tools and arguments
- Anything else that will likely break existing users in some way when they upgrade
Proposed Changes
Describe the new thing you want to do in appropriate detail. This may be fairly extensive and have large subsections of its own. Or it may be a few sentences. Use judgement based on the scope of the change.
Compatibility, Deprecation, and Migration Plan
- What impact (if any) will there be on existing users?
- If we are changing behavior how will we phase out the older behavior?
- If we need special migration tools, describe them here.
- When will we remove the existing behavior?
Test Plan
Describe in few sentences how the KIP will be tested. We are mostly interested in system tests (since unit-tests are specific to implementation details). How will we know that the implementation works as expected? How will we know nothing broke?
Rejected Alternatives
If there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.