Skip to content

Add support for modifying topic replication count #3914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
modax opened this issue May 22, 2025 · 6 comments
Open

Add support for modifying topic replication count #3914

modax opened this issue May 22, 2025 · 6 comments

Comments

@modax
Copy link

modax commented May 22, 2025

Expected Behavior

Topic replica count to be changed if modification is allowed for the topic as per Configuring Topics.

I'm aware that the task is not trivial or straightforward. However, you can get quite some inspiration from the corresponding kafkactl functionality.

Current Behavior

As far as I can tell, org.springframework.kafka.core.KafkaAdmin#addOrModifyTopicsIfNeeded() does not support changing topic replication count. KafkaAdminClient API alterPartitionReassignments() needs to be invoked for this to happen.

Context

I expected this to be supported if spring-kafka is to be used for topic management.

@sobychacko
Copy link
Contributor

@modax Since the underlying KafkaAdmin operation does not support that feature fundamentally, I think any solution that comes up with in the framework will be somewhat custom. However, we can take a look at this and see if there is a way to support this. But, I am not sure when we can get to it, if you have ideas, feel free to work on a POC.

@chickenchickenlove
Copy link
Contributor

Hi. @modax , @sobychacko

Would it be okay for me to take a crack?

@sobychacko
Copy link
Contributor

Sure, please go ahead.

@modax
Copy link
Author

modax commented May 30, 2025

@chickenchickenlove feel free!

@chickenchickenlove
Copy link
Contributor

@modax @sobychacko

I have no idea about the scenario that spring-kafka modifies replication count of existing topic.
kafkactl can do it, because it is ctl. so users will use it when they need to do it.

However, spring-kafka is framework, not a ctl.
IMHO, If spring-kafka users want to modify replicas of existing topic, it would be better for users to use kafkactl or kafka-reassign-partitions.sh for modifying replicas instead of spring-kafka considering that spring-kafka is framework.
As you know, re-built replicas in other broker will take long time even if there are more topic partitions, replicas.

I have no idea about the scenario that spring-kafka modifies replication count of existing topic.
Could you let me know the scenario you imagined before?
Or, Could you please suggest use-case about this.

If so, I'd be happy to consider implementing something tailored to your use case! 🙇‍♂

@modax
Copy link
Author

modax commented Jun 1, 2025

Well, I have encountered this when researching spring-kafka as a way to manage topics. At first I thought it was only able to create new topics. Then I saw it was able to modify topics as well (for example increase partition count). And then saw that this aspect is missing (I mean replicas(X) of NewTopic might get out of date). To be honest, I don't see much difference between kafkactl and spring-kafka with regards to topic management since both already have (some of) it. Just that in case of spring-kafka, it is "closer to the application code".

Now to be honest I don't know the specifics of what it takes for Kafka broker to reassign partitions. In particular, if this can be done a topic being used at the time, how long it takes for replica count to be increased (make sense that synchronization might take some time) or decreased (should be quick, shouldn't it?). As far as I can tell, kafkactl algorithm is pretty smart. It does not reassign existing partitions which are going to be needed anway, but only adds or removes them to match replica count. It also avoids adding multiple partition replicas to the same broker (as far as I can tell anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants