kafka_ex
kafka_ex copied to clipboard
Consumer groups do not rebalance automatically when partitioning changes
The following can occur:
- A topic exists with, say, 4 partitions.
- A KafkaEx consumer group begins consuming from those partitions.
- The topic is reconfigured to have, say, 8 partitions.
- The KafkaEx consumer group will continue to only consume from the initial 4 partitions until a rebalance is forced (e.g., a worker restarts/joins/leaves).
For now this can be managed easily enough by manually restarting a worker, but it should be done automatically. The leader can monitor the metadata for changes relatively easily. I think the main "challenge" will be detecting which changes require a rebalance. The design doc (https://cwiki.apache.org/confluence/display/KAFKA/Kafka+Client-side+Assignment+Proposal) doesn't seem to address this condition specifically, but it could be construed as being covered by the duties of the leader:
The leader of the group can enforce its own policy for controlling the rate of rebalancing. It doesn't have to rebalance after every metadata change, but can "batch" changes together to reduce the impact of metadata churn.