Skip to content
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

Kafka scaler: limit number of replicas to the number of partitions with lag. #3997

Closed
alexakra opened this issue Dec 9, 2022 · 13 comments · Fixed by #5060 or kedacore/keda-docs#1241
Closed
Assignees
Labels
feature-request All issues for new features that have not been committed to help wanted Looking for support from community needs-discussion

Comments

@alexakra
Copy link

alexakra commented Dec 9, 2022

Proposal

I would like to have an option to limit number of replicas to the number of partitions with lag > 0 only.

Use-Case

When using Kafka key, the amount of records per key (partition) not always could be distributed evenly, and in some cases only some partitions have a lag while most of the partitions have no lag.
A special case is when only one partition has a lag which could easily scale to the max allowed number of replicas while all the consumers will be idle except one. In such case there is no need to scale over one replica.
In a general case, I would like to limit scaling to min(max allowed number of replicas as of today, number of partitions with lag > 0). Even though, the partitions could be distributed unevenly between consumers, sometimes it is more efficient way to allocate resources rather than scaling idle consumers.

Anything else?

No response

@alexakra alexakra added feature-request All issues for new features that have not been committed to needs-discussion labels Dec 9, 2022
@zroubalik
Copy link
Member

zroubalik commented Jan 2, 2023

Sounds reasonable. My Kafka knowledge is limited, but could you consider following example:

partitionA - lag = 0
partitionB - lag = 0
partitionC - lag = 100

and we have one active consumer subscribed to partitionA. What would happen if your proposed change is enabled? Is the consumer smart enough the re-subscribe to partitionC in this case?

@alexakra
Copy link
Author

alexakra commented Jan 2, 2023

Usually a consumer subscribes to topic (not to partition), i.e. one active consumer will be subscribed to all partitions.
When number of consumer (the same consumer group) replicas changes, then Kafka broker will split/join the partitions between all the active consumers and rebalancing process will be triggered.

@zroubalik
Copy link
Member

ack, thanks for the clarification.

Are you willing to contribute this feature?

@alexakra
Copy link
Author

alexakra commented Jan 2, 2023

Unfortunately, I am not golang developer.

@zroubalik zroubalik added the help wanted Looking for support from community label Jan 2, 2023
@stale
Copy link

stale bot commented Mar 3, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label Mar 3, 2023
@stale
Copy link

stale bot commented Mar 10, 2023

This issue has been automatically closed due to inactivity.

@stale stale bot closed this as completed Mar 10, 2023
@DmitrySenin
Copy link
Contributor

So was it implemented?

@zroubalik
Copy link
Member

I was not. It was autoclosed, are you interested in contributing this @DmitrySenin ?

@DmitrySenin
Copy link
Contributor

@zroubalik , I would love to try

@stale
Copy link

stale bot commented Apr 20, 2023

This issue has been automatically closed due to inactivity.

@stale stale bot closed this as completed Apr 20, 2023
@zroubalik zroubalik reopened this Apr 24, 2023
@stale stale bot removed the stale All issues that are marked as stale due to inactivity label Apr 24, 2023
@stale
Copy link

stale bot commented Jun 23, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label Jun 23, 2023
@zroubalik zroubalik removed the stale All issues that are marked as stale due to inactivity label Jun 23, 2023
@stale
Copy link

stale bot commented Aug 22, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label Aug 22, 2023
@kamilglod
Copy link

I'm interested in this feature as well - it could be useful for use case where you're manually assigning partition by producer - to e.g. not block all partitions with huge events publication. In that case you end up with only some partitions with lag.

@stale stale bot removed the stale All issues that are marked as stale due to inactivity label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment