Design an Ad Click Aggregation & Counting System
Count billions of ad events with zero fraud loss: Real-time stream aggregation (Apache Flink tumbling windows), exactly-once processing, and ClickHouse OLAP storage.
01.1. Functional & Non-Functional Requirements
An Ad Click Aggregation and Counting System ingests, deduplicates, aggregates, and stores billions of real-time ad impression and click events to power advertiser dashboards, compute Click-Through Rates (CTR), and enforce real-time budget capping.
Functional Requirements
- Real-Time Click & Impression Counting: Ingest and aggregate raw ad click and impression events in real time.
- Multi-Dimensional Querying: Support interactive analytical queries by advertisers:
- "Show total clicks, CTR, and spend for Campaign 8812 grouped by country and device over the past 30 days."
- Click Deduplication & Anti-Fraud: Detect and drop duplicate clicks (e.g. rapid double-clicks within 1 second) and malicious bot fraud.
- Real-Time Budget Capping: Automatically pause an ad campaign within
< 10 secondswhen the advertiser's daily spend budget is exhausted.
Non-Functional Requirements
- Massive Ingestion Throughput: Ingest
> 500,000 click events/secondand5,000,000 impressions/second. - Exactly-Once Processing Guarantees: Ensure no click event is double-counted or lost for advertiser billing accuracy.
- Sub-Second Analytical Queries: Advertiser dashboard queries must execute in
< 500 ms.
Real-Time Ad Click Stream Aggregation Architecture ๐ฏ
Real-Time Ad Click Stream Aggregation Architecture ๐ฏ
Collapsing 500,000 raw clicks/sec into 1-minute tumbling window sums via Apache Flink, sinking pre-aggregated rows into ClickHouse OLAP storage.
Unlock Topic #255: Design an Ad Click Aggregation & Counting System
You are viewing a preview. The full in-depth engineering deep dive, interactive simulators, architecture flowcharts, and self-assessment quizzes for this topic are available with Pro or Lifetime Access.
Failure modes, high-throughput bottlenecks, and real FAANG implementation decisions.
Interactive system topology diagrams, live parameter simulators, and downloadable SVG charts.
Staff-level multiple-choice quiz questions with instant feedback and answer explanations.
Firebase Google authentication automatically syncs your completed topics and quiz scores.
How clear and staff-actionable was this system breakdown?