我在kubernetes集群中部署了Pod,并提供一些HTTPS请求。我正在每秒对并发用户进行api的负载测试。
我在进行负载测试时,由于活动和准备失败而导致容器被杀死,并且吊舱被重新部署。因此,我的API面临失败。
liveness:
initialDelaySeconds: 60
periodSeconds: 20
timeoutSeconds: 60
successThreshold: 1
failureThreshold: 4
readiness:
initialDelaySeconds: 60
periodSeconds: 20
timeoutSeconds: 60
successThreshold: 1
failureThreshold: 4
livenessProbe:
httpGet:
path: /health
port: 8000
scheme: HTTPS
readinessProbe
httpGet:
path: /health
port: 8000
scheme: HTTPS
如何避免这些故障?是因为我的应用程序无法满足活动请求吗?
您需要更确切地说明您正在执行的负载测试。您正在使用哪些工具。
请检查pod
说明以了解导致重新安排Pod的事件日志,这可以通过kubectl describe pod <pod_name>
完成。也许您的pod的内存或CPU不足,因此您可以在Managing Compute Resources for Containers中查看请求和限制。
[您提到在运行测试时readiness和liveness探针失败,这表明您正在向http / https施加压力,使其无法再处理请求。
[要执行探测,kubelet将HTTPS GET请求发送到在容器中运行并且正在侦听端口8000的服务器。如果服务器的/health
路径的处理程序返回成功代码,则kubelet会将容器视为保持健康。如果处理程序返回失败代码,则kubelet将杀死容器并重新启动它。
任何大于或等于200且小于400的代码均表示成功。其他任何代码表示失败。
为了减轻这些故障,您可以增加timeoutSeconds
和/或failureThreshold
,但我认为您应该处理为请求提供服务的流程。
我也建议您阅读这份出色的指南Kubernetes best practices: Setting up health checks with readiness and liveness probes。