Skip to content
SD-13 · System design

Design a Top Shared Articles

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

Design the service behind a news site’s “Most shared” box. Every time a reader shares an article, by link, to a social network or by email, the site records a share event. The box shows the K most shared articles over three windows: the last 24 hours, the last hour and the last 5 minutes. Editors and partner apps read the same lists through an API.

The site records 500 million shares a day, with peaks of 30,000 a second and spikes of 100,000 a second when big news breaks, often with one article taking 30% of all shares. The 5-minute list must move within seconds, all three lists must be right, not roughly right, and a restart must not wipe a day of counts. The hard part is counting in sliding windows at this rate, when one article can be a large share of all traffic.

Good questions to ask first

Decide what you would assume for each before you look at ours.

  1. 1How big is K?
  2. 2Exact or approximate counts?
  3. 3How fresh must the lists be?
  4. 4Sliding or fixed windows?
  5. 5What counts as a share?
  6. 6Global or per country and per section?
  7. 7Do we need old lists?
  8. 8Can editors remove an article?

How to spend the 45 minutes

  1. 5minPart 1: Requirements, windows, exact vs approximate
  2. 5minPart 2: Estimates: rate, skew, state size
  3. 5minPart 3: API
  4. 15minPart 4: Architecture, stage by stage
  5. 15minPart 5: Deep dives: buckets, merge, hot keys, exactly once
Sketch your own design: boxes, arrows and the numbers that matter. Then compare it with ours.Break it in the labVisual walkthrough