News Aggregator

Stories from Many Publishers

Design a service that collects articles from tens of thousands of publisher feeds, groups the ones about the same event into stories, and shows each reader a fresh, ranked front page within minutes of publication.

Overview

A news aggregator does not write news. It reads what thousands of publishers post, groups articles that describe the same event into a story, and shows readers a front page of stories with a headline, a snippet and links out to each publisher.

Three problems make it interesting.

  • Fetching. Publishers expose new articles in feeds (RSS 2.0 or Atom). Checking 50,000 feeds often enough to be fresh, without hammering small sites, is a scheduling problem.
  • Grouping. A wire story is republished almost word for word by hundreds of outlets, while others write their own versions. Exact copies, near-copies and different articles about the same event all need to land in one story.
  • Ranking while things change. A story that is ten minutes old and growing fast matters more than a bigger one from yesterday. The front page must reflect that within minutes.

Questions to ask first

Before drawing anything, pin down the scope with the interviewer. Here is each question, with the answer this design assumes.

  • Where do articles come from? From 50,000 publisher feeds in RSS 2.0 and Atom. A few publishers push updates with WebSub.
  • How many articles? About 2 million new articles a day.
  • What do we store? The headline, snippet, link, time, source and signals. We do not store the full article.
  • How many readers? 50 million a day, with about 5 front-page loads each.
  • How fresh? A new article should be in its story within about 5 minutes, and a breaking story should reach the front page soon after.
  • Is it personalized? Partly. There is a shared top-stories list per region, plus sections ranked by each reader's interests.

The design at a glance

The design has two halves that meet at a cache. The write side is an asynchronous pipeline. Feed fetchers poll publisher feeds, or take WebSub pushes, and put new items on an article queue. Workers take items off the queue, remove duplicates with SimHash, cluster the rest into stories, and store articles and stories. A ranker reads those stories, scores them, watches their velocity, and writes precomputed top lists to a story list cache.

The read side is small by comparison. Readers load shared lists from a CDN, and a feed API re-ranks the cached lists for each signed-in reader. The rest of this chapter follows an article along that path, from the first poll to the front page.

What you will be able to do

  • Schedule polling of tens of thousands of feeds with conditional GET, adaptive intervals and push where offered.
  • Turn RSS and Atom items into one article record with a stable identity.
  • Detect exact and near-duplicate articles with canonical URLs and SimHash.
  • Cluster articles into stories online, and rank stories by freshness, coverage and source quality.
  • Spot a breaking story from how fast articles join it.

Key concepts

  • RSS 2.0 and Atom
  • Conditional GET
  • Adaptive polling
  • WebSub push
  • Canonical URLs
  • SimHash
  • Shingles and MinHash
  • Online clustering
  • Freshness decay
  • Velocity detection

Functional requirements

  • Fetch new items from 50,000 publisher feeds and from WebSub pushes
  • Store each article once, even when it appears in several feeds or is updated
  • Group articles about the same event into a story, with a representative headline
  • Top stories per region and language, and per section (world, business, sports, technology)
  • A personalized front page from followed topics and reading history
  • A story page listing every source that covered it

Non-functional requirements

  • An article appears in its story within about 5 minutes of publication (a target we chose)
  • Front page p99 under about 200 ms (a target we chose)
  • Polite fetching: honor robots.txt, conditional requests and publisher rate limits
  • The read side stays up when the pipeline is behind (serve the last good lists)
  • No single source can flood the front page

Interview questions

  • How do you keep 50,000 feeds fresh without hammering publishers?
  • How do you tell that two articles are the same?
  • How does story clustering work, and how do you fix its mistakes?
  • How do you rank the top stories?
  • How do you personalize without losing the big news?
  • How do you detect breaking news?
  • What happens when a publisher offers WebSub?

Sign up free to read the full topic

More System Design topics

Start free on Cariara · Coding problems · System design studio