Search code examples
httphttp-status-codeshealth-monitoringhealth-check

HTTP health check - GET or HEAD and 200 or 204 response?


I’m wondering if there is a general convention for this: When implementing a HTTP health check for any given application where you are not interested in any response body but just the status code, what would the default/expected endpoint look like?

  • Using a HEAD request - and returning 200 or 204 status code (which one of those?)
  • Using a GET with 204
  • something else?

Solution

  • As of my experience, people use mostly GET and 200. A health check wouldn't respond too much content, so no use of making a HEAD request. But this is mostly the case with a dedicated health check URL.

    Today's cloud systems often use Kubernetes or OpenShift. They appear to use a GET request. I think they'll probably want to get a 200ish response code, so 200-299:

    https://docs.openshift.com/enterprise/3.0/dev_guide/application_health.html

    https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/

    Another example, Drupal defines the HTTP response code to be 200:

    https://www.drupal.org/project/health_check_url

    In Oracle's Infrastructure-as-a-Service docs you can choose between GET and HEAD requests, but the default is HEAD:

    https://docs.oracle.com/en-us/iaas/api/#/en/healthchecks/20180501/HttpMonitor/