For scaling deployments in particular, use a direct object get rather than the /scale API#1458
Merged
Merged
Conversation
… than the /scale API so that it can use the informer cache for better performance. This is annoying as a special case but is so common and improves performance so much that I think it's worthwhile to include. Another option would be to majorly increase the QPS rate limit on the scaling API client however that would also increase kube-apiserver load while watches/informers are generally much less impactful. Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
zroubalik
reviewed
Jan 4, 2021
Member
zroubalik
left a comment
There was a problem hiding this comment.
Looking good, just a minor nit.
4 tasks
1e48733 to
1dde0e9
Compare
Also adds support for StatefulSets for symmetry. Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
1dde0e9 to
4eb4cb0
Compare
zroubalik
reviewed
Jan 5, 2021
| switch { | ||
| case targetGVKR.Group == "apps" && targetGVKR.Kind == "Deployment": | ||
| deployment := &appsv1.Deployment{} | ||
| err := e.client.Get(ctx, client.ObjectKey{Name: targetGVKR.Resource, Namespace: scaledObject.Namespace}, deployment) |
Member
There was a problem hiding this comment.
targetName := scaledObject.Spec.ScaleTargetRef.Name...
Suggested change
| err := e.client.Get(ctx, client.ObjectKey{Name: targetGVKR.Resource, Namespace: scaledObject.Namespace}, deployment) | |
| err := e.client.Get(ctx, client.ObjectKey{Name: targetName, Namespace: scaledObject.Namespace}, deployment) |
Contributor
Author
There was a problem hiding this comment.
Seems weird to use different data sources, increased chance of them being out of sync?
Member
There was a problem hiding this comment.
ScaledObject and the target workload should be always in the sync (the same namespace, if you are asking for this). But in your original code, I don't understand the intention, how do you want to guess the name from targetGVKR.Resource?
Contributor
Author
There was a problem hiding this comment.
I completely misunderstood this code, you are correct :)
| currentReplicas = *deployment.Spec.Replicas | ||
| case targetGVKR.Group == "apps" && targetGVKR.Kind == "StatefulSet": | ||
| statefulSet := &appsv1.StatefulSet{} | ||
| err := e.client.Get(ctx, client.ObjectKey{Name: targetGVKR.Resource, Namespace: scaledObject.Namespace}, statefulSet) |
Member
There was a problem hiding this comment.
targetName := scaledObject.Spec.ScaleTargetRef.Name...
Suggested change
| err := e.client.Get(ctx, client.ObjectKey{Name: targetGVKR.Resource, Namespace: scaledObject.Namespace}, statefulSet) | |
| err := e.client.Get(ctx, client.ObjectKey{Name: targetName, Namespace: scaledObject.Namespace}, statefulSet) |
Co-authored-by: Zbynek Roubalik <726523+zroubalik@users.noreply.github.com> Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
623a21f to
abcf8bb
Compare
Co-authored-by: Zbynek Roubalik <726523+zroubalik@users.noreply.github.com> Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
zroubalik
approved these changes
Jan 6, 2021
ycabrer
pushed a commit
to ycabrer/keda
that referenced
this pull request
Mar 1, 2021
… than the /scale API (kedacore#1458) * For scaling deployments in particular, use a direct object get rather than the /scale API so that it can use the informer cache for better performance. This is annoying as a special case but is so common and improves performance so much that I think it's worthwhile to include. Another option would be to majorly increase the QPS rate limit on the scaling API client however that would also increase kube-apiserver load while watches/informers are generally much less impactful. Signed-off-by: Noah Kantrowitz <noah@coderanger.net> * Update changelog. Signed-off-by: Noah Kantrowitz <noah@coderanger.net> * Use the already-normalized GVKR data so less weird string parsing. Also adds support for StatefulSets for symmetry. Signed-off-by: Noah Kantrowitz <noah@coderanger.net> * Apply suggestions from code review Co-authored-by: Zbynek Roubalik <726523+zroubalik@users.noreply.github.com> Signed-off-by: Noah Kantrowitz <noah@coderanger.net> * Apply suggestions from code review Co-authored-by: Zbynek Roubalik <726523+zroubalik@users.noreply.github.com> Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So that it can use the informer cache for better performance.
This is annoying as a special case but is so common and improves performance so much that I think it's worthwhile to include. Another option would be to majorly increase the QPS rate limit on the scaling API client however that would also increase kube-apiserver load while watches/informers are generally much less impactful.
Checklist
Refs #1449