Unhealthy 与 Degraded .NET 健康检查状态之间的区别是什么 [英] Whats the difference between Unhealthy vs Degraded .NET health check status

查看:10
本文介绍了Unhealthy 与 Degraded .NET 健康检查状态之间的区别是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 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.

我正在尝试使用 新的 ASP.NET Code 2.2 Healthchecks 功能.

I'm trying to use the new ASP.NET Code 2.2 Healthchecks feature.

我应该返回一个带有应用程序状态的 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:

  • 健康
  • 不健康
  • 降级

在哪些情况下应用程序不适合我应该使用 Unhealthy vs Degraded?举几个例子就好了.

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.

这篇关于Unhealthy 与 Degraded .NET 健康检查状态之间的区别是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆