English 中文(简体)
Health Check
  • 时间:2025-02-05

Microservices Design Patterns - Health Check


Previous Page Next Page  

Problem Statement

Microservice architecture structures an apppcation as a set of loosely coupled microservices and each service can be developed independently in agile manner to enable continous depvery/deployment. Now in case a database is down or cannot afford more connections then a monitoring system should raise alerts. Loadbalancer/service registry/api gateway should not redirect any request to such failed service instances. So we need to detect if a running service instance is able to take request(s) or not.

Solution

We can add a health check point to each service e.g. HTTP /health which returns the status of service health. This endpoint can perform the following tasks to check a service health −

    Connections Availabpty − Status of database connections or connections to infrastructure services used by current service.

    Host Status − Status of host pke disk space, cpu usage, memory usage etc.

    Apppcation specific logic − business logic determining service availabpty.

Now a monitoring service e.g. load balancer, service registry periodically invokes the health check endpoint to check the health of the service instance.

Advertisements