-
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
Cache metrics (values) in Metric Server and honor pollingInterval
#2282
Comments
pollingInterval
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. |
In my use-case, not being able to fully control |
What if you specify this in the Prometheus Query? |
This looks like a related issue: |
So the idea is following:
💩 I am not sure how to name this new option, honestly the best would be to name it |
Sorry for the late response. We should think about how to push/pull the metrics between different metrics server instances, as starting point I guess that we could assume the topology is 1-1, but from reliability pov is good idea having 2 or more instances. Maybe we could create a mesh between metrics servers to share the information, but maybe the best idea is just creating a gRPC connections slice and push the metrics using all of them. In background, we could watch (k8s) endpoints for the service and use the chagnes to establish and add new connections to the slice. WDYT? |
I do understand the point you have and I agree. Though in the first iteration I'd try to make this feature as simple as possible. Creating the unary RPC Alternative approach to support multi namespace installations would be to open a client connection from Metrics Server for each installation and send the request the the respective Operator. The filtering would be easy, as the namespace is part of the request from the k8s api when asking for metrics. So we would know (in Metrics Server) which operator ask for the metric. This topology also supports mutliple Metrics Server replicas, as those could be independent because all stuff is stored in the operator. |
okey, let's go with your design and once we check it works, we can modify how we stablish the connections. For the moment we could go 1-1 and then we can think how to solve the connection management. I think that watching KEDA namespaced endpoints to detect new instances and stablish new connections based on that should be a small change |
I'm thinking on the approach and I have one question, will we enforce 1 single operator instance? Docs explain that multiple instances are allowed for HA stuff, even a single instance will work. So we could break the behaviour to them if we stablish the connection against the wrong instance |
The gRPC server start will be hooked on the leader election -> so it will run only on the |
Nice!, I have to think about this slowly to discover potential gaps/issues, but this probably is better solution than mine. Congrats! 👏 |
see this 19cd301 |
@zroubalik I think we can close this? |
@tomkerkhove there is one outstanding sub issue TBD, I'd keep this open till we fix it. |
Proposal
Currently KEDA Metrics Server scrapes metrics values from external services (triggers) with each request from k8s server. This could overload the external service.
keda/pkg/provider/provider.go
Line 72 in 2446b8e
We might want to cache the metric values in Metric Server to reduce the load on the external service and respond to k8s server much faster.
We have
pollingInterval
property in ScaledObject which is being honored only by KEDA Operator, we could extend this behavior to KEDA Metrics Server as well. There could be a new property inScaledObject.spec.advanced
to configure this in case users would like to not cache metric values and keep the original behavior (if we make the new behavior default).The current design
When
useCachedMetrics
option is set totrue
, metrics are queried only during polling interval and stored in Operator. KEDA Metrics Server asks KEDA Operator for metrics through gRPC:useCachedMetrics: true
-> we will hit the cacheuseCachedMetrics: false
or not specifed -> Operator will do the request to the scaler and reply back to KEDA Metrics serverTasks to do:
GetMetrics()
andIsActive()
toGetMetricsAndActivity()
#4015The text was updated successfully, but these errors were encountered: