System Design Masterclass
Searchtop-kstreamingaggregationtime-windowsheapintermediate

Design Top K Most Shared Articles

Design a system to identify the K most shared articles across various time windows

10M+ shares/day, 1M+ articles, multiple time windows|Similar to Twitter, Reddit, Medium, Hacker News, Facebook, LinkedIn|45 min read

Summary

Twitter Trending, Reddit Hot, and news sites all need to surface the most popular content in real-time. The challenge is maintaining accurate counts across millions of events per day while supporting multiple time windows (last hour, day, week) with sub-second query latency. This tests streaming algorithms, approximate counting, and time-series aggregation.

Key Takeaways

Core Problem

This is a streaming aggregation problem with time-windowed counting. We need to maintain running counts and extract top-k efficiently.

The Hard Part

Memory constraints make exact counting of all articles impossible. We need approximate algorithms that guarantee finding truly popular items while using bounded memory.

Scaling Axis

We scale by time-bucketing and sharding by article ID hash. Each shard maintains its local top-k, merged at query time.

The Question: Design a system that identifies the top K most shared articles across different time windows (last hour, last day, last week) with millions of share events per day.

This is a classic problem seen at: - Twitter: Trending topics and tweets - Reddit: Hot posts algorithm - Hacker News: Front page ranking - Medium: Popular articles - News sites: Most read stories

What to say first

Before I design, I want to clarify: What are the time windows we need to support? How fresh must the results be? Is approximate counting acceptable for very popular articles?

What interviewers are testing:

  • Do you understand the memory challenges of counting millions of items?
  • Can you apply streaming algorithms (Count-Min Sketch, Heavy Hitters)?
  • How do you handle time-windowed aggregation?
  • Can you design for both real-time updates and fast queries?

Premium Content

Sign in to access this content or upgrade for full access.