如何避免在Spring应用程序加载时在K8s HPA上出现CPU峰值

huangapple go评论57阅读模式
英文:

How to avoid cpu spike on k8s hpa when spring application is loading

问题

I manage a spring applications on K8s.

Pods take about 2~3 minutes for the application to run, and the probe waiting time is set at 4 minutes.

After re-deploy an application, the CPU Spike symptom occurs while the Pod is being initialized. So, when Rolling Update is performed, all Pods are scaled up due to the CPU spike symptom.

I don't wanna collect a cpu while initializing the application. Is there any way to delay collecting CPU info?

K8s Version : 1.26.3

Deployment Info

...
livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /probex
            port: 9006
            scheme: HTTP
          initialDelaySeconds: 240
          periodSeconds: 60
          successThreshold: 1
          timeoutSeconds: 1
        name: sample-container
        ports:
        - containerPort: 9006
          name: http
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /probex
            port: 9006
            scheme: HTTP
          initialDelaySeconds: 240
          periodSeconds: 60
          successThreshold: 1
          timeoutSeconds: 1
        resources:
          limits:
            memory: 8Gi
          requests:
            cpu: 500m
            memory: 8Gi
...

Hpa Info

...
spec:
  maxReplicas: 5
  metrics:
  - resource:
      name: memory
      target:
        averageUtilization: 70
        type: Utilization
    type: Resource
  - resource:
      name: cpu
      target:
        averageUtilization: 70
        type: Utilization
    type: Resource
  minReplicas: 1
...
英文:

I manage a spring applications on K8s.

Pods take about 2~3 minutes for the application to run, and the probe waiting time is set at 4 minutes.
如何避免在Spring应用程序加载时在K8s HPA上出现CPU峰值

如何避免在Spring应用程序加载时在K8s HPA上出现CPU峰值

After re-deploy an application, the CPU Spike symptom occurs while the Pod is being initialized. So, when Rolling Update is performed, all Pods are scaled up due to the CPU spike symptom.
如何避免在Spring应用程序加载时在K8s HPA上出现CPU峰值

如何避免在Spring应用程序加载时在K8s HPA上出现CPU峰值

I don't wanna collect a cpu while initialize application. Is there any way to delay collect cpu info?

K8s Version : 1.26.3

Deployment Info

...
livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /probex
            port: 9006
            scheme: HTTP
          initialDelaySeconds: 240
          periodSeconds: 60
          successThreshold: 1
          timeoutSeconds: 1
        name: sample-container
        ports:
        - containerPort: 9006
          name: http
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /probex
            port: 9006
            scheme: HTTP
          initialDelaySeconds: 240
          periodSeconds: 60
          successThreshold: 1
          timeoutSeconds: 1
        resources:
          limits:
            memory: 8Gi
          requests:
            cpu: 500m
            memory: 8Gi
...

Hpa Info

...
spec:
  maxReplicas: 5
  metrics:
  - resource:
      name: memory
      target:
        averageUtilization: 70
        type: Utilization
    type: Resource
  - resource:
      name: cpu
      target:
        averageUtilization: 70
        type: Utilization
    type: Resource
  minReplicas: 1
...

答案1

得分: 1

你可以阅读关于 hpa 配置中的 stabilizationWindowSecondsperiodSeconds 参数,并根据你的用例进行调整。

英文:

You can read about stabilizationWindowSeconds and periodSeconds paramters in the hpa configuration and tune them as per your use case.

huangapple
  • 本文由 发表于 2023年6月12日 13:11:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/76453780.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定