Design Application Health Check System – scalable monitoring, alerting, and failure detection for thousands of backend apps

Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2020-03-25

Problem Statement

Modern organizations run thousands of microservices, APIs, and backend applications across distributed infrastructure (cloud, containers, hybrid). Ensuring scalable health monitoring, failure detection, and alerting is critical to minimize downtime and improve reliability.


You are asked to design a Health Check System that can monitor thousands of backend apps, detect failures quickly, trigger alerts, and provide a dashboard for observability.


✅ Functional Requirements


1.Health Monitoring
•Periodic checks (HTTP heartbeat, gRPC ping, TCP, custom probes).
•Capture latency, response codes, error rates.
•Configurable intervals per service.
2.Failure Detection & Alerting
•Detect unhealthy instances/services (fast but with minimal false positives).
•Support alert thresholds (e.g., 3 consecutive failures).
•Notify via multiple channels (Slack, Email, PagerDuty, SMS).
3.Dashboard / Visualization
•Display real-time health status of all apps.
•Service dependency graph (show cascading failures).
•Historical metrics and SLA/SLO compliance.
4.Scalability
•Handle thousands of services across multiple regions.
•Auto-discovery of services (Kubernetes, service registry, config).
5.Configurability
•Different probe types (HTTP, gRPC, custom scripts).
•Flexible retry & timeout policies.


❌ Non-Functional Requirements


•Low Latency: Fast detection of failures (<30s ideally).
•High Availability: Monitoring system must not be a single point of failure.
•Scalability: Scale to 100K+ checks per second.
•Reliability: Avoid false positives due to transient network issues.
•Multi-tenancy: Support monitoring apps from multiple teams/organizations.


🧱 System Components


1.Agent / Probe Service
•Deployed per node/region (sidecar or daemonset).
•Performs health checks and sends results upstream.
2.Health Check Orchestrator
•Assigns probes to agents.
•Ensures balanced load and redundancy.
3.Ingestion Layer (Message Queue/Stream)
•Kafka/Pulsar/Kinesis for scalable ingestion of health check results.
4.Processing & Aggregation Layer
•Aggregates results, applies thresholds, detects failures.
•Stores time-series data for visualization.
5.Storage
•Time-Series DB (Prometheus, TimescaleDB, InfluxDB) → store check results.
•Config Store (etcd, Consul, DynamoDB) → service configs, thresholds.
6.Alerting Engine
•Rule-based triggers (e.g., 3/5 probes failed).
•Integrates with PagerDuty, Slack, Email, Webhooks.
7.Dashboard/UI
•Real-time view of all monitored services.
•Drill-down per app, region, and instance.
•SLA/SLO reporting.


🔄 Example Flow


1.Health Check Orchestrator assigns probes → Agents perform checks.
2.Results streamed to Kafka → Processing Layer aggregates.
3.If service fails threshold → Alert Engine triggers Slack/PagerDuty alert.
4.Results stored in Time-Series DB → Dashboard displays status.


⚖️ Trade-offs & Design Considerations


•Push vs Pull Monitoring: Should apps push their status (push model) or should probes pull (active monitoring)?
•Distributed Agents: Reduce latency vs central probes (but harder to manage).
•Storage Cost: Raw vs aggregated metrics (trade-off between accuracy and storage).
•Failure Detection: Conservative thresholds (avoid false positives) vs aggressive detection (fast alerts).
•Multi-region design: Failover between monitoring clusters.


🧪 Open Discussion Points


•How do you handle service discovery in dynamic environments like Kubernetes?
•Should the system auto-remediate (restart app, scale up) or only alert?
•How to handle network partitions where agents can’t reach apps (false alarms)?
•How would you design this system to monitor 100K+ microservices across multiple cloud regions?


👉 This problem tests monitoring, distributed systems, fault tolerance, scalability, and alerting trade-offs — very similar to what’s expected in SRE / System Design interviews.

Solution

Comments