Scope
Functional
- Ingest click (and impression) events.
- Query aggregated counts per ad / campaign / advertiser per minute, with filters (country, device).
- Top-N most-clicked ads in the last M minutes.
Non-functional
- Dashboard freshness ~1 minute. Billing accuracy: no double counting, no loss.
- 10B clicks/day → ~115k/s average, ~500k/s peak.
- Late events accepted up to ~1 hour (mobile apps buffer clicks offline).
Size
- Event ≈ 200 B → 2 TB/day raw.
- Aggregates: ~2M active ads × 1,440 minutes × a few dimensions → billions of small rows per day, which a columnar OLAP store handles.
The pipeline
The 30-second summary
Say it in the interview
"Clicks are ingested with unique IDs into Kafka, deduplicated and fraud-filtered in a Flink job that aggregates in one-minute event-time windows with watermarks and allowed lateness. Exactly-once comes from checkpointed state, transactional output and idempotent upserts into ClickHouse. Hot ads are pre-aggregated, a separate job maintains top-N, and a daily batch over the raw archive reconciles the numbers used for billing."
Follow-up questions the interviewer may ask
- How do you avoid counting the same click twice?
- How do you filter click fraud?
- Advertisers want counts per minute for 90 days. What changes?
- How do you reconcile the real-time and batch numbers?
Model answers to each of these are in the book.