SD-20 · Back to the write-up
Design a Web Analytics Pipeline
Collect into a log, drop bots and pre-aggregate in a stream with sketches, keep raw events in a columnar store, and let dashboards read the small rollups.
Follow a request
Collect a page view
Open a dashboard
Custom report on raw events
Nightly recompute
Stream crash and replay
Browsers
Ingest
Processing
Storage
VisitorTag on the page
Site ownerDashboard
Script CDNtag.js
CollectorsStateless
Query APIRollups first
Event logBy site, 7 days
Stream processorBots, rollups, HLL
Batch recomputeNightly
Raw eventsColumnar
RollupsMinute, hour, day
The numbers, at a glance
3 bots, dropped7 counted
21 TBM1
64 TBM3
128 TBM6
192 TBM9
277 TBM13
72 GB hourly rollups700 GB of raw events a day
A page view, in order
The visitor’s part ends at 204; everything after it is off the page’s path.
Browser
Collector
Event log
Stream
Rollups
Raw store
1 sendBeacon /collect
2 append (site partition)
3 ack, 2 of 3 copies
4 204
5 event stream
6 upsert minute rollup
7 batch of raw events
RequestResponseAsync, does not block
Where dashboard numbers come from
The decision this question is really about.
widget
scan billions of rows
seconds per chart
+ Any question, exact.− 2,000 scans a second.
event
+1 counter
raw thrown away
+ Tiny and fast.− No raw data to fix or explore.
event → log
stream rollups + HLLraw columnar
nightly recompute
+ Fast reports, raw kept for the rest.− Two paths to keep in step.
How it grows
Add a box only when a number forces you to. Highlighted boxes are new at each stage.
BrowserOwner
App server
SQL table
BrowserScript CDN
Collectors
Event logStream loader
Columnar store
BrowserScript CDN
Collectors
Event logStream rollups + HLL
Columnar storeRollup store
BrowserScript CDN
Collectors
Event logStream rollups + HLLBatch recompute
Columnar storeRollup store
Was this walkthrough useful?Your vote tells us what to improve next.