Design a Web Analytics Pipeline
Design a web analytics product. A website owner pastes a small script into their pages; every page view and custom event, such as signup or add_to_cart, is sent to us. The owner opens a dashboard and sees visitors, page views, top pages, referrers, countries and devices for any date range, plus a live count of who is on the site right now.
A million websites use it, sending 10 billion events a day, up to 350,000 a second at peak. The hard parts: collecting events so cheaply that we never slow a customer’s page and never drop data, answering a dashboard question over billions of events in under a second, counting *unique* visitors without keeping a list of every visitor, and keeping numbers honest when 30% of hits come from bots and some events arrive hours late.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1How fresh must dashboards be?
- 2Which reports?
- 3How exact must unique visitors be?
- 4How long do we keep data?
- 5How do we know a visitor?
- 6Do we filter bots?
- 7Time zones?
- 8Who can see a dashboard?
How to spend the 45 minutes
- 5minPart 1: Requirements and scope
- 5minPart 2: Estimates
- 5minPart 3: API
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Deep dives and trade-offs