Design an ad click aggregator
Design a system that ingests click and view events from a large website, and lets people query aggregates — clicks per page per hour, top referrers, conversion counts — over the last two years.
About this problem
“Design an ad click aggregator” is a core-level problem in the data pipelines family. Enormous volume in, aggregates out, and nobody is waiting for any single event.
The key challenge: Minutes, sometimes hours, of slack on every output. In this group the usual mistake is failing to use it.
Time budgets: Ingestion: must not drop. Aggregates: minutes to hours. Historical: rebuild whenever.
The worked solution for Click analytics goes through why those budgets shape the design, stage by stage.
Before you start
You will work this in five timed stages. Here is what each one asks you to think about. None of it is the answer; the answers unlock in the workspace below once you have written your own.
- Stage 1 · Requirements · 5 min
- Exact counts or approximate? Ask, because it changes the storage design.
- What queries will people actually run? That decides the shape.
- What happens to an event if ingestion is down?
- Stage 2 · Actors and lifecycle · 6 min
- The event starts in a browser that may close at any moment.
- What happens when an aggregation job produces wrong numbers?
- What about events that arrive hours late?
- Stage 3 · Numbers · 6 min
- Events per second, and what does that mean in bytes?
- Two years of raw events is how much?
- How much smaller is the aggregated data? That ratio is the design.
- Stage 4 · High-level design · 12 min
- What does the ingestion endpoint actually do? Keep it small.
- Where do raw events live, and where do aggregates live?
- How is the aggregation partitioned?
- Stage 5 · Deep dive and tradeoffs · 14 min
- What happens when one page gets 90% of the traffic?
- Someone asks for exact unique visitors over a year. Walk through it.
- The aggregation job had a bug for a week. Now what?
Work it through
Five stages, gated. You write your answer for each stage before its model answer unlocks. That is the core of the method.
Done all five? The diagrams, numbers, trade-offs and follow-ups for this problem are on the worked solution page, to check your own design against.
How it is really built
Write your own answer first. Then read how teams who run this at scale describe it. Their constraints were real, and the write-ups often say what their choices cost.
- Apache Kafka — Design ↗A common choice for the durable, replayable ingestion log.