SysPadExamples › Ad click event aggregation

Ad click event aggregation

Click events are deduplicated once, then split into a real-time stream aggregator (fast, approximate) and a raw-event archive feeding a periodic batch reconciliation job (slow, accurate).

The real-time-vs-batch accuracy trade-off, sharing one dedup gate.

Ad Clients Users Click Event Stream MSK Dedup Cache ElastiCache Stream Aggregator Lambda Real-time OLAP OpenSearch AT LIMIT Raw Event Archive S3 Batch Reconciliation EMR AT LIMIT Ad Warehouse Redshift AT LIMIT

How it works

Dedup Cache
The single gate both paths pass through: a click id seen before is dropped once, here, so neither the real-time count nor the archive ever double-counts a retried event.
Stream Aggregator
The fast, approximate path: windowed counts land in the OLAP store within seconds, good enough for live dashboards but not guaranteed exact.
Raw Event Archive
Every deduplicated event, kept verbatim - the source of truth the nightly batch replays to correct whatever the real-time path got approximately wrong.
Batch Reconciliation
The slow, exact path: it re-aggregates the full archive on a schedule and overwrites the approximate numbers in the warehouse with reconciled ones.

Request flows

Count a click

  1. Ad Clients
  2. Click Event Stream
  3. Dedup Cache
  4. Stream Aggregator
  5. Real-time OLAP
  6. Raw Event Archive

Nightly reconciliation

  1. Raw Event Archive
  2. Batch Reconciliation
  3. Ad Warehouse

Other interview practice

Open this architecture in SysPad · All examples