Ad Click Aggregation

Count billions of ad clicks per day in near real time with accurate billing totals.

Hard50 minStream processingWindowsExactly-once

An ad click aggregation system counts billions of ad clicks per day, per ad and per minute, for real-time dashboards and for billing advertisers. Because the numbers become invoices, the design must handle duplicates, late events, and failures without over- or under-counting.

Clarify requirements

Functional

  • Ingest click events: click_id, ad_id, campaign_id, user_id, ts, ip, country, device.
  • Query click counts per ad (and campaign) over the last M minutes, aggregated per minute.
  • Top-N most clicked ads in the last M minutes, filterable by country/device.
  • Feed billing with accurate daily totals.
  • Out of scope: impression tracking (same pipeline pattern), fraud ML models (integrate as a filter).

Non-functional

  • 10B clicks/day; peak 5x average.
  • Dashboard freshness within ~1 minute.
  • Billing accuracy: exactly-once counting (no double counting, no loss); final totals reconciled.
  • Handle late events (mobile clients offline) up to some bound.
  • Fault tolerant, horizontally scalable.

Try it first

Set a timer, sketch your own design on paper, then compare it with the reference walkthrough.

50:00

Complete & continue

Defend it out loud

The AI interviewer will probe your design for Ad Click Aggregation and score it.

Mock interview