Kubernetes - Scale up interval

9/24/2019

I am using Kubernetes in GCP. I am scaling my pods using metrics of queue size uploaded to Cloud Monitoring.

The problem: Kubernetes scale up pods in very short intervals. About 12-15 seconds between each scale up. My machines take about 30 seconds to boot up. I would like the scale up intervals to be something close to 30.

Adding

spec: minReadySeconds: 30

to the deployment yaml did not worked.

Example hpa:

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: <NAME>
  namespace: <NAMESPACE>
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: <DEPLOYMENT>
  minReplicas: <MIN_REPLICAS>
  maxReplicas: <MAX_REPLICAS>
  metrics:
  - type: External
    external:
      metricName: "custom.googleapis.com|rabbit_mq|<QUEUE>|messages_count"
      metricSelector:
        matchLabels:
          metric.labels.name: <NAMESPACE>
      targetValue: <TARGETVALUE>

Is there a way to control this scale-up interval?

-- Montoya
google-cloud-platform
google-kubernetes-engine
kubernetes

1 Answer

9/24/2019

The delays between scale-ups are determined internally by the HPA algorithm.

From the documentation:

Starting from v1.12, a new algorithmic update removes the need for the upscale delay.

It seems it was a configurable parameter before, but now the algorithm tries to be smart about it and decide on its own how quickly to scale up your app.

To be really sure how the HPA does it and how you could influence it, you can inspect the code.

-- weibeld
Source: StackOverflow