Service Fabric Application Health Check

喜欢而已 提交于 2019-12-25 01:36:02

问题


Is it possible to periodically check the health of an application? I have two scenarios in mind:

  • During deployment I want service fabric to rollback if the health check fails
  • Application is successfully running but still want to periodically run a health check in case a dependency is unavailable

Currently I expose a healthcheck operation and I have traffic manager polling it. I have the following to flag it as unhealthy..

var context = FabricRuntime.GetActivationContext();
context.ReportApplicationHealth(new HealthInformation("source", "healthcheck", HealthState.Error));

This works but I was hoping to add a health check policy which will poll this endpoint periodically as opposed to relying on an external component. Also, from a deployment perspective I want it to rollback if for example the app failed to start (missing config, DI misconfigured etc).

Am I barking up the wrong tree here? I am assuming these health check policies will give me what I need but unsure how to configure it..


回答1:


I'd recommend using the 'side-car pattern'. You'd deploy a service dedicated to monitoring the other service. The 'watchdog' service would be able to ping /check the other periodically and report about its health.

By delegating the monitoring work, you can detect and report service unhealthiness even if the guarded service stops responding all together, for example when it's caught in a never ending wait.

I've found a few links about this topic that may be helpful:

  • This page
  • And this one.


来源:https://stackoverflow.com/questions/54865122/service-fabric-application-health-check

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!