HealthChecks
HealthChecks copied to clipboard
Implements Canary endpoint
The Canary endpoint provides a binary health status of the application. Dead or alive. This endpoint is designed for HTTP load balancer, responding 200 HTTP status or 503 HTTP status.
This endpoint may be controlled either by the IHealthcheckService or by an application switch. For example : The application must be upgraded. On the current node , the operator will switch off the application. Even with the application off, the application will continue to respond to others requests. The load balancer will remove the current node from its healthy nodes list and will reroute requests to others nodes. The application will not receive any request and can be stopped/killed/upgraded.
The same case can occur with the healthcheck service. If the application is unhealthy, the canary endpoint will respond 503 and the load balancer will remove the current node from the healthy nodes list
This is similar to the app_offline.htm file, but app_offline.htm has the drawback to reply 502 to the clients.
You can do this with the current middleware by adding a healthcheck that looks for the existence of a file or some other flag from an operator. Right?
Right!
I first take a look at the environment variables as flag, but I discovered that they were not updated. A simple file watch as flag is correct. We can imagine also any something based on Redis pubsub feature.