System Design (50 Qs)•Part 2: Real-World High-Scale Architecture Problems (11 - 25)
Design a Web Analytics / Event Tracking Platform (Kafka + ClickHouse / Druid).
In Simple Words: Ingest, aggregate, and query 10 billion daily user interaction events (pageviews, clicks, scroll depth) with real-time dashboard visualization.
Storage Architecture: Columnar vs Row-Oriented:
- Row-oriented databases (PostgreSQL/MySQL) are designed for single-row OLTP operations.
- Columnar Databases (ClickHouse / Apache Druid) store table data column-by-column on disk. Reading and aggregating billions of rows (
SELECT count(*), avg(duration) GROUP BY country) only reads the specific requested columns, compressing data by 90% and executing queries in milliseconds!
Architecture Flowchart
flowchart LR
SDK["Browser / Mobile JS SDK"] -->|"HTTP POST (Batched)"| Collector["Event Ingestion Gateway"]
Collector --> Kafka["Apache Kafka Cluster"]
Kafka --> Flink["Apache Flink (Real-time Window Aggregation)"]
Kafka --> ClickHouse["ClickHouse Columnar Storage"]
ClickHouse --> Dashboards["Real-Time Analytics Dashboard UI"]