Build a Real-Time Story-Grouping News Feed Platform
System DesignModel answerLast updated
Design a platform that pulls in millions of articles daily, removes syndicated copies, groups coverage into evolving stories, and serves fast ranked feeds to tens of millions of users.
Problem
You are asked to design a news aggregation product. It continuously collects articles from a large set of publishers, recognizes republished or lightly edited copies, groups coverage of the same real-world event into one "story", and gives each reader a ranked, partly personalized list of current stories.
What the system must do
- Collect: Regularly poll RSS feeds and publisher sites, extracting body text, metadata and publication time.
- Remove copies: Catch byte-identical duplicates and near-identical syndicated versions (for example, wire-service text reposted by many outlets).
- Group into stories: Put articles about the same event into one story entity, even when the outlets and wording differ.
- Surface breaking news: Detect stories that are growing quickly and promote them.
- Serve feeds: Offer an endpoint returning top stories per category, adjusted by simple user preferences (topics, followed or blocked sources).
Quality targets
- A new article should be processed, deduplicated and clustered within 5 minutes of publication.
- Feed reads: p99 under 150 ms.
- Read path availability: 99.99%.
- The system should absorb breaking-news surges where read traffic is 2-3x normal.
Scale
- 50,000 publishers or feeds
- 10 million new articles per day (about 120/s average, 500/s peak)
- 50 million daily active users, around 25,000 read QPS at peak
- Stories are clustered within a rolling 7-day window; older ones move to cold storage
What to cover in your answer
- End-to-end architecture, from fetching to the user-facing API.
- The dedup and clustering pipeline: algorithms and data structures (for example, locality-sensitive hashing for near-duplicates, and incremental vector matching versus batch clustering).
- Data model and storage choices for articles, stories and user interactions.
- Feed generation, caching and how you score breaking or trending stories.
- Trade-offs and edge cases: crawler politeness, drift in long-lived stories, spam and low-quality sources.
Hints
Hint 1
Split the system into a heavy asynchronous write pipeline (fetch, parse, dedup, embed, cluster, score) and a cheap, cacheable read path. Connect the stages with a durable log so you get replay and backpressure.
Hint 2
Do not run global clustering per article. Compare each new article against the centroids of currently active stories using an approximate nearest-neighbor index, and run a periodic batch job to repair merge and split mistakes.
Hint 3
Treat near-duplicates as signal, not waste: keep them linked to a canonical article so the story can show how many outlets carry it. Precompute feeds per category and region, and apply personalization only as a light merge and filter at read time.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Framing
The core design decision is to separate a heavy, asynchronous write pipeline from a light, cache-first read path. Most of the interesting depth is in dedup, clustering and ranking, not in the crawler.
1. Clarify and size
Assumptions: we store extracted text internally and serve only snippets and links; content is multilingual (so use a multilingual encoder); personalization is topic/source preferences plus light engagement signals, not a full recommender.
| Item | Estimate |
|---|---|
| Ingest | 10M/day, ~120/s avg, 500/s peak |
| Raw text | ~10 KB each, ~100 GB/day, ~700 GB in the 7-day hot window |
| Embeddings | 384-d float16 is ~768 B, so ~55 GB for 70M articles |
| Active stories | ~5-10% of article count, ~5M; centroid index ~4 GB, fits in memory per shard |
| Fetches | 50k feeds, adaptive polling 1-30 min, ~100-500 fetches/s |
| Reads | 25k QPS peak, plan for ~75k in a surge |
2. API sketch
GET /v1/feed?category=&cursor=&limit=returns story cards (headline, top 3 articles, source count, updated time).GET /v1/clusters/{id}returns full coverage.PUT /v1/users/me/preferencessets topics, followed and blocked sources.POST /v1/eventsrecords impression, click, dwell.
3. Architecture
Scheduler -> fetch queue (Kafka, keyed by domain) -> crawler workers
-> parser (boilerplate removal, language, timestamps)
-> exact dedup -> near-dup (SimHash/LSH) -> embedder (GPU batches)
-> clusterer (ANN over active centroids, sharded)
-> scorer / trend detector (stream job)
-> feed builder -> Redis precomputed feeds -> stateless Feed API -> CDN
Kafka between stages gives replay, backpressure and independent scaling. Latency budget for the 5-minute SLA: up to ~3 minutes of crawl delay (adaptive polling plus WebSub push where supported), then ~30 s for parse, dedup, embed, cluster and score.
4. Dedup and clustering
Exact duplicates. Normalize URLs (strip tracking parameters and fragments, lowercase host, follow rel=canonical, collapse AMP variants). Hash the normalized body with SHA-256. Keep both keys in a KV store with a 7-day TTL; a hit means alias or drop.
Near-duplicates. Compute a 64-bit SimHash over word shingles. Duplicate if Hamming distance is at most 3. To find candidates without scanning, split the hash into 4 bands of 16 bits and index each band; by pigeonhole, any pair within distance 3 shares at least one identical band. MinHash with Jaccard of at least 0.8 is an alternative that tolerates partial overlap better. Do not delete near-dups: set canonical_article_id so the story can say "carried by 40 outlets", which is also an importance signal.
Story clustering (incremental).
- Embed headline plus lead paragraphs; optionally add named entities.
- Query an HNSW index of active story centroids (last 7 days) for top-k candidates, pre-filtered by time and category.
- Score
α·cosine + β·entity_overlap + γ·time_decay. If the best score is above a tuned threshold (about 0.75, tuned on labeled pairs), attach and update the centroid with a running mean or EMA; otherwise open a new story. - Shard by category or region. Serialize writes to one story through a single-writer partition (key by story id) or optimistic versioning.
- Run an hourly batch job (HDBSCAN or agglomerative on the 7-day window) to merge fragments and split incoherent stories, correcting greedy online mistakes.
Batch-only clustering over 70M items cannot meet the 5-minute SLA; ANN lookup against ~5M centroids costs a few milliseconds.
5. Data model
- articles (wide-column store, PK
article_id): url, canonical_url, source_id, title, snippet, lang, published_at, simhash, content_hash, cluster_id, canonical_article_id. - clusters: id, centroid, anchor embedding, headline, category, entities, first_seen, last_updated, article_count, source_count, velocity, status.
- cluster_articles (PK cluster_id, clustering key published_at desc) for the coverage view.
- sources (relational): domain, feed URLs, authority score, crawl interval, robots rules, spam flag.
- user_prefs (relational plus cache); user_events into Kafka, then the warehouse, with aggregates as Redis counters.
- feeds (Redis):
feed:{category}:{region}is a sorted set of the top ~500 story ids;cluster_card:{id}holds rendered JSON. - Raw HTML in an object store; archived stories in Parquet.
6. Feed generation and ranking
Precompute global, category and region lists every 30-60 s, and immediately for high-velocity stories. With about 30 categories and 50 regions that is roughly 1,500 lists, which is cheap.
Personalize at read time: fetch 2-4 candidate lists (followed topics plus top stories), merge, drop blocked sources, re-weight with a cached preference vector, and hydrate cards with one MGET. That is 2-3 Redis round trips and under 20 ms of compute, comfortably inside 150 ms p99.
Ranking score combines recency decay, source count weighted by source authority, arrival velocity, and engagement (CTR, dwell). Trending detection compares the story's arrival rate and distinct-source count in a short sliding window against its own baseline; a sudden ratio jump triggers a boost.
Spikes and availability. CDN-cache anonymous and top-story responses for 30-60 s, which absorbs most of a 3x surge. Autoscale stateless API pods. Replicate Redis across zones. Degrade gracefully: if personalization fails, serve the generic feed; if Redis fails, serve the last snapshot from an in-process cache.
7. Trade-offs and edge cases
- Crawler politeness: honor robots.txt and crawl-delay, apply per-domain rate limits (Kafka keyed by domain helps), use conditional GET (ETag / Last-Modified), back off on errors, prefer push where available.
- Cluster drift: a story that evolves over days can pull in unrelated articles as its centroid moves. Anchor against the first-hour embedding as well as the running centroid, cap centroid movement, and split via the batch job.
- Spam and low quality: source authority scores, spam flags, minimum-source requirements before a story is promoted, and rate anomaly checks to resist coordinated content farms.
- Threshold tuning: a low threshold merges distinct events; a high one fragments stories. Prefer slight fragmentation online and let the batch merge fix it.
- Late or backdated articles: use event time with a bounded lateness window.
Common mistakes
- Clustering globally per article instead of against active centroids.
- Discarding near-duplicates and losing the syndication-count signal.
- Computing personalized feeds from scratch per request instead of precomputing shared lists and merging.
- Ignoring crawler politeness and failure modes.
- Spending the whole answer on the crawler and little on clustering and ranking.