Design a Real-Time Analytics System
Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2024-10-15
Problem Statement
Design a Real-Time Analytics Platform** that ingests high volumes of event data (e.g., page views, clicks, transactions, sensor data) from multiple sources, processes it in real time, and provides:
•Low-latency dashboards
•Aggregated metrics (e.g., counts, averages, error rates)
•Live alerts and notifications
•Support for ad-hoc queries
The system should be horizontally scalable, highly available, and fault-tolerant to handle billions of events per day.
🎯 Functional Requirements:
1.Real-Time Event Ingestion
•Support high throughput event streams (clicks, logs, etc.)
•Support multiple sources (web, mobile, backend systems)
2.Stream Processing & Aggregation
•Compute metrics like counts, rates, trends (per second/minute/hour)
•Support windowing (tumbling, sliding)
3.Storage
•Store raw events for replay or historical analysis
•Store aggregated metrics for fast retrieval
4.Dashboards and APIs
•Low-latency APIs to fetch live and recent analytics
•Real-time updating dashboards
5.Alerting
•Define alert conditions (e.g., spike in traffic, drop in conversion rate)
•Trigger notifications via webhook, Slack, email
6.Ad-Hoc Query Support
•Allow querying raw and aggregated data (e.g., last hour’s errors from service X)
⚙️ Non-Functional Requirements:
•<1 second end-to-end latency from event to metric
•Support horizontal scaling of ingestion and processing
•Exactly-once or at-least-once event semantics
•Fault tolerance & durability
•Event volume: millions of events per second