-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 Partitions Per Pod Scaling #2581
Comments
Here is a list of pod scaling sequences based on partition count:
Here is the Scala code that generated the above list:
|
This would be great for ensuring that only impactful scaling happens with Kafka consumers, especially since all values between p/2 and p-1 are essentially noop for scaling (they all have at least one consumer with 2 partitions). |
the Kafka scaler already fakes the metrics to cap the instance count at the partition count. keda/pkg/scalers/kafka_scaler.go Lines 452 to 457 in 28d0b69
Could similarly fake the metric value to result in the desired instance count. Not saying if that's a good idea or not, but I think it would work. |
That approach just caps the max reported metrics, not replicas. But yeah, you are right, it could be done somehow, but it would need to mimic HPA algorithm and report fake metrics, that's not ideal imho. But happy to see some POC :) |
It's essentially The existing code do a max where |
In theory this could work, I am curious how precise the calculation will be and if we are able to really convince the HPA to scale accordingly. @rwkarg keen to give it a try? |
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. |
Haven't had any time to look at this, but it would be a nice improvement. |
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. |
This issue has been automatically closed due to inactivity. |
Generally this has been how we've scaled our Kafka consumers when managing replica count manually, so some way to do so with autoscaling would be great as well to help guarantee that we have an even distribution of work (assuming relatively even distribution of messages across partitions) for our consumers. |
@mwarkentin are you willing to contribute this? :) |
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. |
Looks like stalebot is ignoring the |
I need to revise my sequence algorithm. It is only considering scale steps where all pods get the same number of partitions. For example at 8 total partitions scaling from 2 to 3 is impactful as you go from 4,4 to 3,3,2. |
@gabrieljones ack, are you willing to contribute this once you are okay with the algorithm? |
@zroubalik, I would like to take it on. Would be a nice starter project for me. |
@patelvp great! |
@zroubalik I have most of the pieces here #6343. |
Not sure if this helps. I have been working on a multi k8s cluster aware direct autoscaler. It does not use metrics and it bypasses the hpa logic altogether. It uses the hpa merely to adjust the minReplicas. It directly adjusts the |
@gabrieljones That is a great idea that could work. I can extend that idea to just pull the current replica count. Because that is what I want to make this work more natively. |
TBH I am not completely sure we should pull the actual replica count - there might be multiple scalers defined so the final replica count might be affected by another scaler. We should imho do the calculation similar way like the fallback feature. @gabrieljones this is interesting, is the scaler public? Can we check it out? |
Proposal
Enhance the Kafka Scaler or create a new KEDA Scaler to support scaling Kafka by partitions per pod as opposed to simple increase in pod count.
Use-Case
Say I have 12 partitions for my topic.
At 3 pods I will have four partitions per pod:
4 + 4 + 4 = 12
At 4 pods I will have three partitions per pod:
3 + 3 + 3 + 3 = 12
If I naively scale to 5 pods, I will end up with 3 pods with 2 partitions each and 2 pods with still 3 partitions each:
2 + 2 + 2 + 3 + 3 = 12
To scale correctly I need to jump from 4 pods directly to 6 pods:
2 + 2 + 2 + 2 + 2 + 2 = 12
And instead of scaling to 7, 8, 9, 10, or 11, it should scale directly from 6 to 12.
1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 = 12
As such the list of valid scale targets is not a simple sequence from 0 to 12. It is rather a sequence of the divisors of the partition count:
0, 1, 2, 3, 4, 6, 12
Anything else?
No response
The text was updated successfully, but these errors were encountered: