Health Checks

When you add HTTP(S) Endpoints, Enclave performs health checks on your App Containers when deploying and throughout their lifecycle.

Health Check Modes

Health checks on Enclave can operate in two modes:

Default Health Checks

In this mode (the default), Enclave expects your App Containers to respond to health checks with any valid HTTP response, and does not care about the status code.

Strict Health Checks

When Strict Health Checks are enabled, Enclave expects your App Containers to respond to health checks with a 200 OK HTTP response. Any other response will be considered a failure.

To enable Strict Health Checks, set the STRICT_HEALTH_CHECKS Configuration variable on your App to the value true. This will setting apply to all Endpoints associated with your App.

Warning

Redirections are not 200 OK responses, so be careful with e.g. SSL redirections in your app that could cause your app to respond to the health check with a redirect, such as Rails’ config.force_ssl = true.

Overall, we strongly recommend verifying your logs first to check that you are indeed returning 200 OK` on ``/healthcheck before enabling Strict Health Checks.

Health Check Lifecycle

Enclave performs health checks at two stages:

Release Health Checks

When deploying your app, Enclave ensures that new app containers are receiving traffic before they’re registered with load balancers.

When Strict Health Checks are enabled, this request is performed on /healthcheck, otherwise, it is simply performed at /. In either case, the request is sent to the Container Port for the Endpoint.

Release Health Check Timeout

By default, Enclave waits for up to 3 minutes for your app to respond. If needed, you can increase that timeout by setting the RELEASE_HEALTHCHECK_TIMEOUT Configuration variable on your app.

This variable must be set to your desired timeout in seconds. Any value from 0 to 900 (15 minutes) seconds is valid (we recommend that you avoid setting this to anything below 1 minute).

You can set this variable using the aptible config:set command:

aptible config:set --app "$APP_HANDLE" \
        RELEASE_HEALTHCHECK_TIMEOUT=600

Runtime Health Checks

Note

This health check is only executed if your Service is scaled to 2 or more Containers.

When your app is live, Enclave periodically runs a health check to ensure that your Containers are still accepting traffic:

  • If one or more of your App Containers are not passing the health check, traffic will be routed to other healthy containers.
  • If none of your App Containers are passing the health check, traffic will be routed to Brickwall.

This health check is performed as a HTTP request sent to /healthcheck. Your app must respond with a 200 if Strict Health Checks are enabled, and with any status code otherwise.

Tip

If needed, you can identify requests to /healthcheck coming from Enclave: they’ll have the X-Aptible-Health-Check header set.