Guides

Health checks

How the host decides an app is up, and the three kinds of check.

config.healthCheck tells the host whether an instance is healthy. It is required; there is no default. It has two jobs: a wake waits for it to pass before forwarding the request, and after that the host polls it for liveness.

"healthCheck": {
  "kind": "http",
  "path": "/healthz",
  "intervalMs": 5000,
  "timeoutMs": 2000,
  "gracePeriodMs": 30000,
  "healthyThreshold": 1,
  "unhealthyThreshold": 3
}

Kinds

kindHealthy when
httpGET path on httpPort returns 2xx.
tcpA connection to httpPort is accepted. For ports that do not speak HTTP.
boot-completedThe microVM is up and httpPort has accepted one connection. For a guest image you did not build, which serves no health path.

http and tcp use all the timing fields: intervalMs, timeoutMs, gracePeriodMs, healthyThreshold and unhealthyThreshold. boot-completed uses none: the app has 30 seconds to start listening, and nothing is checked after that. An instance that fails unhealthyThreshold checks in a row is reported unhealthy, with the reason.

Prefer http

A TCP connect is accepted by the guest kernel whether or not the process behind it will ever read the request. A hung program passes tcp for as long as it lives. Use http unless the app has no HTTP endpoint.

Restarts

config.restartPolicy limits how often the host restarts the program after it exits:

"restartPolicy": {
  "maxRestarts": 5,
  "initialBackoffMs": 500,
  "maxBackoffMs": 30000,
  "backoffFactor": 2,
  "resetAfterMs": 60000
}

The wait before each attempt starts at initialBackoffMs, is multiplied by backoffFactor each time, and is capped at maxBackoffMs. If the program stays up for resetAfterMs, the restart count resets. After maxRestarts failures, the instance is reported failed and is not restarted until it is deployed again with a new deploymentId.

The reference lists every field of a health check and a restart policy.

On this page