KEDA scaledown event take 5 minute

1k views Asked by At

My pods used to scale down in few seconds 20-30 but i dont know what happened now it taken 5 minute to scale down and when I added minreplica in KEDA YML file the time from 1 to 0 pods take few seconds but for n to 1 pod it take 5 minutes what I understanded that thus HPA behaviour it take the responsability of scale down from n ->1 pod and from 1->0 pod KEDA is responsible for the event I added this to scaledobject file but its being ignored

spec:
  scaleTargetRef:
    name: consumer-deployment
  pollingInterval: 5
  cooldownPeriod: 10
  minReplicaCount: 0
  maxReplicaCount: 5

how to reduce this time that is by default 5 minute

**Im using k8s with docker desktop **

1

There are 1 answers

2
Fariya Rahmat On

As mentioned in the document :

The period to wait after the last trigger reported active before scaling the resource back to 0. By default it’s 5 minutes (300 seconds).

The cooldownPeriod only applies after a trigger occurs; when you first create your Deployment (or StatefulSet/CustomResource), KEDA will immediately scale it to minReplicaCount. Additionally, the KEDA cooldownPeriod only applies when scaling to 0; scaling from 1 to N replicas is handled by the Kubernetes HPA.

Your cool down period will be dependent on pollingInterval. This is the interval to check each trigger on. By default KEDA will check each trigger source on every ScaledObject every 30 seconds. So you can minimize pollingInternal time to reduce your cool down period.

However,you can enable/disable scaling rules either by editing the replica count to 0 or you can use a single field called Pause autoscaling.

Add this below annotation to your deployment :

metadata:
   annotations:
      autoscaling.keda.sh/paused-replicas: "0"

This annotation will pause autoscaling no matter what number of replicas is provided. The above annotation will scale your current workload to 0 replicas and pause autoscaling. You can set the value of replicas for an object to be paused at any arbitrary number. To enable autoscaling again, simply remove the annotation from the ScaledObject definition.