Health checks
How each service of a load balancer probes its targets, the settings and their ranges by type, and how a target leaves and rejoins rotation.
A health check belongs to a service, not to the load balancer: every service probes every target on its own. A target that fails a service's check stops receiving that service's traffic and gets it again once it passes.
Settings
| Setting | Values | Default |
|---|---|---|
healthCheckProtocol |
http: a GET of the path, 2xx or 3xx is healthy. tcp: a connection is enough. |
http |
healthCheckPath |
the path to GET; when changed later, it must start with / and have at most 256 characters (adding a service does not check it) |
/ |
healthCheckInterval |
seconds between checks: 3–60 on lb11/lb21/lb31, 1–60 on application and dedicated |
15 |
healthCheckTimeout |
seconds a check may take, 1–60 and at most the interval | 10 |
healthCheckRetries |
failed checks in a row before a target stops taking traffic, 0–5 | 3 |
healthCheckPort |
dedicated only: the port to probe instead of the target port |
the target port |
The check is made against the service's destination port on each target, unless a dedicated
service sets healthCheckPort. The console's Add service form sets only the path; the other
settings are set with the CLI, API or Terraform, when the service is added or later. See
Change a health check or sticky sessions.
On application and dedicated
The fleet's machines run the check. A target leaves rotation after healthCheckRetries failed
checks in a row (at least one) and comes back after two passing ones. Each machine of the fleet
checks every target itself. The target's status in the API and the console is the result the
fleet's active machine reports: healthy or unhealthy. Before its first report, a new target
shows unknown on application and healthy on dedicated. Either way, a new target takes traffic
as soon as the fleet carries it, until the check takes it out. The Live tab shows each target's health as each
machine sees it.
On http and https services, a GET, HEAD or OPTIONS request without a body that cannot
connect to its target is tried once on another target.
On lb11, lb21 and lb31
The provider runs the check with the settings of the service. A target's status in the API and
the console is not the check's result: it stays healthy.
Close connections on a failed check (dedicated, tcp)
With closeOnUnhealthy: true on a dedicated tcp service, the open connections to a target
are closed when its health check answers no (an HTTP status outside 2xx and 3xx, healthCheckRetries
times in a row), so clients reconnect to another target. A check that only times out stops new
connections to the target and closes nothing. This suits a database primary endpoint, with an
HTTP check on a port that answers 2xx only on the primary.