不健康状态与降级的.NET健康检查状态之间有什么区别 [英] Whats the difference between Unhealthy vs Degraded .NET health check status
问题描述
我有一个在Kubernetes中运行的应用程序.为了利用滚动更新而不造成停机的优势,我必须实施适当的运行状况检查,以便群集可以知道应用程序/容器何时可以处理请求.
I have an application running in Kubernetes. To take the advantage of rolling updates with no downtime, I have to implement the proper Health Checks, so the cluster can know when the application/container is ready to handle requests.
我正在尝试使用我应该返回具有应用程序状态的Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult
结构.
I should return a Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckResult
struct with the status of the application.
此结构具有3个静态方法,可用于返回此状态:
This struct has 3 static methods that I can use to return this status:
- 健康
- 不健康
- 降级
在哪种情况下应用程序运行不正常,我应该使用不健康"还是降级"?一些例子将是很好的.
In which situations that the app is not OK that I should use Unhealthy vs Degraded? A few examples would be good.
推荐答案
降级"检查可以用于确实成功但速度缓慢或不稳定的检查.例如.一个简单的数据库查询确实成功了,但是花费了超过一秒钟的时间.在问题解决之前,将流量转移到另一个实例可能是一个好主意.
A "degraded" check could be used for checks that did succeed but are slow or unstable. E.g. a simple database query did succeed but took more than a second. Moving traffic to another instance is probably a good idea until the problem has resolved.
不健康"检查表示该组件完全不起作用.例如.无法建立与Redis缓存的连接.重新启动实例可以解决此问题.
An "unhealthy" check means that the component does not work at all. E.g. a connection to the Redis cache could no be established. Restarting the instance could solve this issue.
引用博客文章:
活动探针失败:该应用程序已崩溃.你应该 关闭它,然后重新启动.
A failed liveness probe says: The application has crashed. You should shut it down and restart.
准备就绪探针失败:应用程序正常,但尚未准备就绪 服务流量.
A failed readiness probe says: The application is OK but not yet ready to serve traffic.
您可以说降级"的健康检查映射到就绪"探针,而不健康的"检查映射到活跃度"探针.
You could say that a "degraded" health check maps to the "readiness" probe and an "unhealthy" check maps to the "liveness" probe.
这篇关于不健康状态与降级的.NET健康检查状态之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!