kedacore / keda

KEDA is a Kubernetes-based Event Driven Autoscaling component. It provides event driven scale for any container running in Kubernetes
https://keda.sh
Apache License 2.0
8.38k stars 1.06k forks source link

Triggers for same type not working #5755

Closed samuelteixeiras closed 3 months ago

samuelteixeiras commented 5 months ago

Report

I have a trigger configuration that uses 3 triggers from the same type prometheus, and the scale is not working for the first trigger metadata related to response time. triggers:

Expected Behavior

The scaler would scale up and down if the threshold of each Prometheus metric is reached.

Actual Behavior

The scaler is ignoring the response time metrics. My threshold is 20ms and my application is over that value and the number of pods is not increasing.

Steps to Reproduce the Problem

  1. Set multiple triggers with the same type prometheus
  2. Reach the different thresholds
  3. Verify id the scaler is respecting all triggers

Logs from KEDA operator

example

KEDA Version

2.11.2

Kubernetes Version

1.28

Platform

Amazon Web Services

Scaler Details

ScaledObject

Anything else?

No response

JorTurFer commented 5 months ago

Hello, Are you using AverageValue or Value metric type for the time trigger? You haven't set it and as default KEDA uses AverageValue (as it's explained here), so if you have 20ms and 20 pods, the (average) value is 1, which is under the threshold indeed.

image

You can extend the scaling differences based on metric types here: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/

samuelteixeiras commented 5 months ago

Hi, thank you for the reply. I did not set the type, so it's using the default the AverageValue. Saying that, all pods will have the same metric value: histogram_quantile(0.99, sum(irate(istio_request_duration_milliseconds_bucket{namespace="my-app-namespace"}[5m])) by (le)) The value returned by the query is for all pods, if this returns 30ms, I believe it's 30ms for all k8s pods. So using AverageValue or Value would not make a difference.

Before I had only one Prometheus trigger and the Scaler was respecting the threshold

JorTurFer commented 5 months ago

Saying that, all pods will have the same metric value: histogram_quantile(0.99, sum(irate(istio_request_duration_milliseconds_bucket{namespace="my-app-namespace"}[5m])) by (le)) The value returned by the query is for all pods, if this returns 30ms, I believe it's 30ms for all k8s pods. So using AverageValue or Value would not make a difference.

It makes the difference totally, as it's the HPA Controller who applies the difference 😄

You are returning 30ms with can be for all pod in your prometheus server, but using AverageValue the HPA controller will take that value and make the average using current pod count.

You can read more about the HPA algorithm here https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#algorithm-details image

Before I had only one Prometheus trigger and the Scaler was respecting the threshold

Was your original single trigger based on the response time? Your other triggers are probably okey, the only one that needs to be value 100% is the time based

samuelteixeiras commented 5 months ago

thank you once more:D , I will try to change it to Value, if works as expected I am going to close the issue.

Was your original single trigger based on the response time? Yes

JorTurFer commented 5 months ago

I will try to change it to Value, if works as expected I am going to close the issue.

Let me know how it goes :)

Was your original single trigger based on the response time? Yes

That's truly weird xD

stale[bot] commented 3 months ago

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[bot] commented 3 months ago

This issue has been automatically closed due to inactivity.