mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-19 11:25:58 +00:00
21f7b026f5
* Add Health Check pattern implementation The commit introduces Health Check pattern, providing a series of health indicators for system performance and stability monitoring, including checks for system CPU load, process CPU load, database health, memory usage, and garbage collection metrics. It also includes asynchronous execution and caching mechanisms for health checks, and retry configurations for resilience. Implements health checking components as per issue #2695. * Test cases and javadoc for HealthEndpointIntegrationTest * Added more log to test case to see why it returns 503 * Change config values to see if the system High system CPU load is resolved or not in CI. * Fixes for test cases. * some fixes for Sonar. * some fixes for Sonar. ADDED HIGH_PROCESS_CPU_LOAD_MESSAGE_WITHOUT_PARAM ADDED HIGH_SYSTEM_CPU_LOAD_MESSAGE_WITHOUT_PARAM * Sonar fixes address "Define and throw a dedicated exception instead of using a generic one." added HealthCheckInterruptedException refactored CustomHealthIndicator * fixes checkstyle violation.
title, category, language, tag
| title | category | language | tag | |||
|---|---|---|---|---|---|---|
| Health Check Pattern | Performance | en |
|
Health Check Pattern
Also known as
Health Monitoring, Service Health Check
Intent
To ensure the stability and resilience of services in a microservices architecture by providing a way to monitor and diagnose their health.
Explanation
In microservices architecture, it's critical to continuously check the health of individual services. The Health Check Pattern is a mechanism for microservices to expose their health status. This pattern is implemented by including a health check endpoint in microservices that returns the service's current state. This is vital for maintaining system resilience and operational readiness.
Class Diagram
Applicability
Use the Health Check Pattern when:
- You have an application composed of multiple services and need to monitor the health of each service individually.
- You want to implement automatic service recovery or replacement based on health status.
- You are employing orchestration or automation tools that rely on health checks to manage service instances.
Tutorials
- Implementing Health Checks in Java using Spring Boot Actuator.
Known Uses
- Kubernetes Liveness and Readiness Probes
- AWS Elastic Load Balancing Health Checks
- Spring Boot Actuator
Consequences
Pros:
- Enhances the fault tolerance of the system by detecting failures and enabling quick recovery.
- Improves the visibility of system health for operational monitoring and alerting.
Cons:
- Adds complexity to service implementation.
- Requires a strategy to handle cascading failures when dependent services are unhealthy.
Related Patterns
- Circuit Breaker
- Retry Pattern
- Timeout Pattern
Credits
Inspired by the Health Check API pattern from microservices.io and the issue #2695 on iluwatar's Java design patterns repository.
