When you add HTTP(S) Endpoints, Aptible performs health checks on your App Containers when deploying and throughout their lifecycle.
Health Check Modes
Health checks on Aptible can operate in two modes:
Default Health Checks
In this mode (the default), Aptible 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, Aptible expects your App Containers to respond to health checks with a
200 OK HTTP response. Any other response will be considered a failure.
Strict Health Checks are useful if you're doing further checking in your app to validate that it's up and running.
To enable Strict Health Checks, set the
STRICT_HEALTH_CHECKS Configuration variable on your App to the value
true. This setting will apply to all Endpoints associated with your App.
📘 The Endpoint has no notion of what hostname the App expects so it sends health check requests to your application with
containersas the host. This is not a problem for most applications but for those that only allow the use of certain hosts, such as applications built with Django that use
ALLOWED_HOSTS, this may result in non-200 responses. These applications will need to exempt hostname checking or add
containersto the list of allowed hosts on
❗️ Redirections are not
200 OKresponses, 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
/healthcheckbefore enabling Strict Health Checks.
Health Check Lifecycle
Aptible performs health checks at two stages:
- Release Health Checks when releasing new app Containers.
- Runtime Health Checks throughout the lifecycle of your app Containers.
Release Health Checks
When deploying your app, Aptible 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, Aptible 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
📘 This health check is only executed if your Service is scaled to 2 or more Containers.
When your app is live, Aptible 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 an HTTP request sent to
/healthcheck. Your app must respond with a 200 if Strict Health Checks are enabled and with any status code otherwise. See Endpoint Logs for information about how Runtime Health Checks error logs can be viewed.
📘 If needed, you can identify requests to
/healthcheckcoming from Aptible: they'll have the