英文:
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.
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 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 配置中的 stabilizationWindowSeconds
和 periodSeconds
参数,并根据你的用例进行调整。
英文:
You can read about stabilizationWindowSeconds
and periodSeconds
paramters in the hpa configuration and tune them as per your use case.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论