Best Practices for Microservices: Health Checks
36%
Health Checks
One of the best practices in developing microservices is to implement the health check pattern.
A health check is a mechanism to monitor the health of an application or service. It's used to determine if the application is running properly and can handle requests. It is used by the infrastructure to determine whether a microservice is healthy or not. If a microservice is not healthy, it is cut off from the network and no longer receives requests.
Kubernetes is able to restart an unhealthy microservice automatically, replacing its Pod with a new one. It also has the mechanism to avoid sending requests to a microservice that is:
- Not ready: for example, it is still running an init container.
- Starting up: it is in the process of starting up but is not yet ready.
- Shutting down: it is in the process of shutting down and should not receive new requests.
- Unhealthy: it is not functioning properly.
Cloud-Native Microservices With Kubernetes - 2nd Edition
A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in KubernetesEnroll now to unlock all content and receive all future updates for free.
