Skip to content
SD-20 · System design

Design a Web Analytics Pipeline

Asked at Senior level45 minutes
Our answers stay hidden until you reveal them.

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.

  1. 1How fresh must dashboards be?
  2. 2Which reports?
  3. 3How exact must unique visitors be?
  4. 4How long do we keep data?
  5. 5How do we know a visitor?
  6. 6Do we filter bots?
  7. 7Time zones?
  8. 8Who can see a dashboard?

How to spend the 45 minutes

  1. 5minPart 1: Requirements and scope
  2. 5minPart 2: Estimates
  3. 5minPart 3: API
  4. 15minPart 4: Architecture, stage by stage
  5. 15minPart 5: Deep dives and trade-offs
Sketch your own design: boxes, arrows and the numbers that matter. Then compare it with ours.Break it in the labVisual walkthrough