0
0
HLDsystem_design~7 mins

Health check endpoints in HLD - System Design Guide

Choose your learning style9 modes available
Problem Statement
When a service or server fails silently or becomes unresponsive, the system cannot detect the failure quickly. This leads to prolonged downtime, poor user experience, and difficulty in automated recovery or scaling decisions.
Solution
Health check endpoints provide a simple URL or API that external systems can call to verify if a service is running correctly. These endpoints return a status indicating the health of the service, enabling monitoring tools and load balancers to detect failures and take action automatically.
Architecture
┌───────────────┐       ┌───────────────┐       ┌───────────────┐
│   Client /    │       │   Load        │       │   Service     │
│ Monitoring    │──────▶│   Balancer    │──────▶│   Instance    │
│ System        │       │               │       │               │
│ (Health       │       │               │       │  ┌─────────┐  │
│  Checker)     │       │               │       │  │Health   │  │
└───────────────┘       └───────────────┘       │  │Check    │  │
                                                │  │Endpoint │  │
                                                │  └─────────┘  │
                                                └───────────────┘

This diagram shows a monitoring system or load balancer querying the health check endpoint of a service instance to verify its status before routing traffic.

Trade-offs
✓ Pros
Enables quick detection of service failures for automated recovery.
Improves system reliability by allowing load balancers to avoid unhealthy instances.
Simplifies monitoring by providing a standard way to check service health.
Can include detailed checks for dependencies, improving fault diagnosis.
✗ Cons
Requires additional development and maintenance effort for health check logic.
If health checks are too simple, they may not detect deeper issues.
Overly complex health checks can increase response time and resource usage.
Use when running multiple service instances behind load balancers or when automated monitoring and recovery are needed, especially at scales above tens of instances.
Avoid if the system is a single instance without automated monitoring or if the overhead of health checks outweighs benefits in very small or simple deployments.
Real World Examples
Netflix
Netflix uses health check endpoints to ensure that streaming servers are responsive before routing user requests, preventing buffering and downtime.
Amazon
Amazon employs health checks in its Elastic Load Balancer to detect unhealthy EC2 instances and reroute traffic to healthy ones automatically.
Google
Google Cloud Platform uses health check endpoints to monitor VM instances and managed services, enabling auto-healing and scaling.
Alternatives
Heartbeat mechanism
Instead of a request-response endpoint, services send periodic signals to a monitoring system to indicate health.
Use when: Choose when you want push-based health reporting rather than pull-based checks, especially in systems with limited incoming request capability.
External monitoring agents
Use separate agents installed on servers to monitor service health rather than built-in endpoints.
Use when: Choose when you want to monitor multiple aspects of the host environment beyond just the service.
Summary
Health check endpoints help detect service failures quickly by providing a simple status URL.
They enable automated systems like load balancers and monitors to maintain system reliability.
Properly designed health checks balance thoroughness with performance to avoid overhead.