DEV Community

Hans Christian Bartelt
Hans Christian Bartelt

Posted on

GraphQL Mesh Readiness & Health Check

In container orchestration platforms like Kubernetes, health checks and readiness checks are probes that help to ensure the reliability and availability of containerized applications.

When deploying GraphQL Mesh with mesh start on Node.js, the built-in Yoga Server provides the endpoints /healthcheck and /readiness out of the box.

Health Check

Health check probes periodically check the container's internal state to ensure it's healthy.

Endpoint /healthcheck returns HTTP 200 when successful:

curl "http://localhost:4000/healthcheck" -v

> GET /healthcheck HTTP/1.1
> Host: localhost:4000
> User-Agent: curl/7.86.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 28 Feb 2023 10:56:42 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
< Content-Length: 0
<
Enter fullscreen mode Exit fullscreen mode

Readiness Check

Readiness probes check whether the container is ready to handle traffic:

Endpoint /readiness returns HTTP 204 when ready or HTTP 503 when not.

curl "http://localhost:4000/readiness" -v

> GET /readiness HTTP/1.1
> Host: localhost:4000
> User-Agent: curl/7.86.0
> Accept: */*
>
< HTTP/1.1 204 No Content
< Date: Tue, 28 Feb 2023 10:56:44 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
<
Enter fullscreen mode Exit fullscreen mode

Kubernetes Example

The Kubernetes livenessProbe and readinessProbe configuration would look like this:

livenessProbe:
  httpGet:
    path: /healthcheck
    port: http
  initialDelaySeconds: 5
  periodSeconds: 10
readinessProbe:
  httpGet:
    path: /readiness
    port: http
  initialDelaySeconds: 5
  periodSeconds: 5
Enter fullscreen mode Exit fullscreen mode

Top comments (0)