Design a real‑time monitoring system
Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2025-04-01
Problem Statement
Designing a real-time monitoring system that collects, processes, and visualizes metrics, logs, and alerts from distributed services and infrastructure. The system should support scalability, low latency, and high availability, enabling engineers to monitor system health and troubleshoot issues in real time.
Design a Real-Time Monitoring System that can ingest, store, query, and visualize large-scale metrics with low latency, provide alerting capabilities, ensure high availability, and scale to millions of events per second while supporting customizable dashboards and secure multi-tenant access.
🔶 Functional Requirements
1.<span></span>Metrics Collection
2.<span></span>Collect metrics (CPU, memory, latency, error rates, etc.) from distributed servers, services, and applications.
3.<span></span>Support custom metrics (business KPIs, app-specific counters).
4.<span></span>Data Ingestion & Storage
5.<span></span>Handle high-volume, high-frequency data streams.
6.<span></span>Store time-series metrics efficiently for querying and visualization.
7.<span></span>Query & Visualization
8.<span></span>Provide a query interface for developers to fetch metrics.
9.<span></span>Offer dashboards and charts for real-time visualization.
10.<span></span>Alerting System
11.<span></span>Define rules (e.g., "CPU > 80% for 5 min").
12.<span></span>Trigger alerts in real time via email, Slack, PagerDuty, etc.
13.<span></span>Support threshold-based and anomaly-based alerts.
14.<span></span>Scalability & Reliability
15.<span></span>Scale to handle millions of metrics per second.
16.<span></span>System should be fault-tolerant with replication and recovery.
17.<span></span>Security & Access Control
18.<span></span>Ensure only authorized users can view/query metrics.
19.<span></span>Support role-based access (admin, developer, read-only).
🔶 Non-Functional Requirements
1.<span></span>Low Latency: End-to-end metric propagation < 5 seconds.
2.<span></span>High Availability: 99.9% uptime SLA.
3.<span></span>Data Retention: Configurable (e.g., raw data 7 days, aggregated data 1 year).
4.<span></span>Cost Efficiency: Support tiered storage (hot vs. cold).
🔶 Constraints
1.<span></span>Must handle real-time streaming ingestion (millions of events/sec).
2.<span></span>Metrics can come from heterogeneous sources (servers, containers, APIs).
3.<span></span>Support distributed deployment across multiple data centers or cloud.
🔶 Example Use Cases
1.<span></span>Monitoring server CPU, memory, and disk usage across 10,000+ machines.
2.<span></span>Tracking API request latency and error rates for a microservices-based app.
3.<span></span>Alerting SREs when error rate spikes beyond a threshold.
4.<span></span>Generating dashboards for business metrics (daily active users, transactions/sec).