call(back)

Design a Clickstream Pipeline for a Billion Events a Day

Design the data platform for a streaming service whose web, mobile and TV apps emit clickstream events: page views, taps, play, pause and seek, ad impressions, device heartbeats. About a billion events a day. The business wants two things from one pipeline: dashboards (active users, plays per title, ad impressions per campaign, funnels) that are fresh within minutes, and accurate, finalized daily aggregates that finance can trust.

Cover the path from the client SDK through an edge collector, a durable log, processing, storage and serving, with back-of-envelope numbers that justify each choice: events per second at average and peak, event size, bytes per day, partition counts, processor parallelism. Then the follow-ups: how you detect that the pipeline is falling behind and keep it caught up during spikes without dropping events; how daily aggregates stay accurate when devices sync telemetry hours or days late; and how you get exactly-once results in Spark or Flink when clients retry and brokers redeliver.

Hints

Hint 1

Do the arithmetic first: a billion a day is about 11,600 per second on average and 5 to 10 times that at peak; at a kilobyte each that is a terabyte of raw events a day, which sizes the log, its partitions and the retention.

Hint 2

Two consumers, two paths: a stream processor over event time with watermarks for the minute-fresh view, and a nightly batch over the full day in the lake for the finalized numbers, with the batch allowed to correct the stream.

Hint 3

Exactly-once is idempotence plus checkpoints: a unique event id from the SDK, deduplication keyed on it within a window, checkpointed processor state, and sinks that upsert by key rather than append.

Asked at

Similar Problems6