Guides

Health checks

What tells the host an app is up, and the three ways to say it.

config.healthCheck is what tells the host an instance is well. Every instance names one — there is no default — and it does two jobs: a wake waits for it before handing the caller on, and liveness is read from it after that.

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

The three kinds

kindHealthy means
httppath, requested on httpPort, answers 2xx.
tcpA connection to httpPort is accepted. For a port that does not speak HTTP.
boot-completedThe microVM is up and httpPort has accepted a connection once. For a guest this host did not build, which answers no path it was not told about.

http and tcp carry the timing above: intervalMs, timeoutMs, gracePeriodMs, healthyThreshold and unhealthyThreshold. boot-completed carries none — the app has 30 seconds to start listening, and nothing is timed after that. An instance that fails its check unhealthyThreshold times in a row is reported unhealthy, with why.

Good to know

Use http when you can. A TCP connect is answered by the guest kernel's accept queue whether or not the process behind it will ever read the request, so a program that has stopped answering passes tcp for as long as it lives.

Restarts

config.restartPolicy is the budget for starting the program again after it exits:

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

The wait before each attempt grows from initialBackoffMs by backoffFactor, capped at maxBackoffMs. A program that stays up for resetAfterMs earns the whole budget back. Past maxRestarts, the instance is reported failed and is not started again until it is deployed afresh, under a new deploymentId.

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

On this page