Design a Real-Time News Story Aggregator
System DesignModel answerLast updated
Architect a high-throughput news feed system that ingests raw articles, groups duplicate reports into single event clusters, and serves personalized timelines at scale.
Design a large-scale news aggregation system capable of pulling content from thousands of external publishers, web crawlers, and syndicated feeds to display a consolidated story feed to millions of users.
Requirements
- Ingestion Pipeline: Collect raw articles, extract content metadata, and filter exact or near-identical republications (e.g., syndicated wire stories).
- Story Clustering: Detect articles describing the same real-world event and merge them into a single, cohesive story cluster. A user viewing the feed should see one master entry per event; expanding it reveals the individual publisher reports.
- Feed Retrieval & Personalization: Construct timelines based on topic interest, source diversity, story freshness, and click behavior.
- Data Models & APIs: Detail the core entities, storage tiers, and RESTful endpoints for feed fetch, cluster breakdown, and telemetry.
- Operational Reliability & Scalability: Address system bottlenecks, caching strategies, backpressure management, and cluster ID stability.
Scale Assumptions
- Ingestion: ~50,000 distinct source feeds generating 2 million raw articles daily (~25 writes/sec average, 300 writes/sec peak).
- Read Traffic: 100 million daily active users (DAU), average 10 feed reads per day (~11,500 QPS average, 50,000 QPS peak).
- Latency SLA: Feed rendering under 200 ms (p99); ingestion-to-cluster availability within 3 minutes.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. System Requirements & System Metrics
Functional Requirements
- Multi-Source Ingestion: Ingest articles via RSS, web scraping, and direct partner APIs.
- Content Deduplication & Clustering: Detect identical wire reprints (exact/near-duplicate) and group distinct articles covering the same event into a Story Cluster.
- Cluster Representation: Pick a canonical headline, representative cover image, and list of covering outlets for each cluster.
- Timeline Presentation: Deliver a main feed of story clusters sorted by a combination of global trend velocity and personalized user preference.
- Drill-down View: Fetch all underlying articles, publisher links, and metadata for a specific cluster.
Non-Functional Requirements
- Low Latency: Feed fetching p99 under $200\text{ ms}$.
- Freshness Target: Newly ingested content must be clustered and visible in hot candidate pools within $3\text{ minutes}$.
- High Read Availability: Read feeds should remain accessible ($99.99%$) even if downstream ML re-rankers or offline clustering jobs degrade.
- Cluster ID Stability: Story IDs must remain invariant while users scroll through a feed session to prevent visual jumping.
Back-of-the-Envelope Scale
- Content Ingestion Volume: $$\frac{2,000,000 \text{ articles/day}}{86,400 \text{ sec/day}} \approx 23.1 \text{ articles/sec}$$ Peak Ingestion: $\sim 300\text{ articles/sec}$ during major breaking news events.
- Raw Ingestion Storage: $$2,000,000 \times 15\text{ KB/article} \approx 30\text{ GB/day}$$ $$30\text{ GB/day} \times 30\text{ days active window} \approx 900\text{ GB active storage}$$
- Embeddings Volume (768-dim FP16): $$768 \times 2\text{ bytes} \approx 1.5\text{ KB/article}$$ $$2,000,000 \times 1.5\text{ KB} \approx 3\text{ GB/day}$$
- Read Traffic Volume: $$\frac{100,000,000\text{ DAU} \times 10\text{ requests}}{86,400\text{ sec}} \approx 11,574\text{ QPS}$$ Peak Traffic: $\sim 50,000\text{ QPS}$.
2. API Design
Consumer APIs
1. Fetch User Feed
GET /v1/feed
- Query Parameters:
cursor(string, optional): Opaque base64 token encodingsnapshot_timestampandoffset.limit(int, default=20): Page size limit.language(string, default="en"): ISO language code.
- Response:
{
"data": [
{
"cluster_id": "cls_98f7a2d4",
"canonical_headline": "Global Climate Summit Reaches Historic Energy Accord",
"cover_image_url": "https://cdn.news.com/img/98f7a2d4.jpg",
"source_count": 42,
"top_sources": [
{"name": "Reuters", "domain": "reuters.com"},
{"name": "Associated Press", "domain": "apnews.com"},
{"name": "BBC News", "domain": "bbc.com"}
],
"first_seen_at": 1711958400,
"last_updated_at": 1711962000,
"categories": ["world", "environment"]
}
],
"paging": {
"next_cursor": "eyJzbmFwc2hvdCI6MTcxMTk2MzAwMCwib2Zmc2V0IjoyMH0="
}
}
2. Get Articles in Cluster
GET /v1/clusters/{cluster_id}/articles
- Query Parameters:
cursor,limit. - Response:
{
"cluster_id": "cls_98f7a2d4",
"articles": [
{
"article_id": "art_11ab22cd",
"publisher": "Reuters",
"title": "Nations agree to transition away from fossil fuels at climate summit",
"url": "https://reuters.com/world/climate-accord-2024",
"published_at": 1711958400,
"snippet": "Delegates from nearly 200 countries approved a groundbreaking treaty..."
}
],
"paging": { "next_cursor": null }
}
3. Log Interaction Event
POST /v1/telemetry/events
- Payload:
{
"events": [
{
"event_type": "CLICK",
"cluster_id": "cls_98f7a2d4",
"article_id": "art_11ab22cd",
"timestamp": 1711962150
}
]
}
3. Data Storage Model
┌───────────────────────┐
│ PostgreSQL DB │
│ (Publisher Registry) │
└───────────────────────┘
│
┌───────────────────┴───────────────────┐
▼ ▼
┌──────────────┐ ┌──────────────┐
│ Cassandra │ │ Redis Cache │
│(Articles & │ │(Hot Feed & │
│ Clusters) │ │ Candidate) │
└──────────────┘ └──────────────┘
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ S3 Store │ │ Vespa / Qdrant│
│(Raw HTML/Text│ │ Vector Search│
└──────────────┘ └──────────────┘
Key Storage Engines
- Cassandra / ScyllaDB: Stores core article metadata and cluster memberships. Partition key design prevents hot-spotting while enabling high write throughput.
- AWS S3 / GCS: Stores heavy unstructured content (raw HTML, cleaned body markup).
- Vespa / Qdrant: Vector database holding 768-dimensional sentence embeddings for recent articles and cluster centroids (72-hour sliding window).
- Redis Cluster: Stores precomputed feed candidate pools and user interaction context.
Database Schema Definitions
articles (Cassandra)
CREATE TABLE articles (
article_id text,
publisher_id text,
canonical_url text,
title text,
body_s3_uri text,
published_at timestamp,
language text,
simhash bigint,
cluster_id text,
topics set<text>,
PRIMARY KEY (article_id)
);
cluster_memberships (Cassandra)
CREATE TABLE cluster_memberships (
cluster_id text,
published_at timestamp,
article_id text,
publisher_id text,
title text,
PRIMARY KEY ((cluster_id), published_at, article_id)
) WITH CLUSTERING ORDER BY (published_at DESC, article_id ASC);
clusters (Cassandra)
CREATE TABLE clusters (
cluster_id text,
canonical_article_id text,
first_seen_at timestamp,
last_updated_at timestamp,
article_count int,
source_count int,
topics set<text>,
centroid_vector vector<float, 768>,
PRIMARY KEY (cluster_id)
);
4. End-to-End System Architecture
INGESTION & DEDUPLICATION PIPELINE
Publishers / RSS / Crawlers
│
▼
┌──────────────────────┐
│ Ingestion Poller/Svc │
└───────────┬──────────┘
│
▼
┌──────────────────────┐ ┌─────────────────────┐
│ Kafka: raw-articles ├─────►│ Near-Dup Detector │ (SimHash / LSH)
└───────────┬──────────┘ │ (Wire-copy Filter) │
│ └──────────┬──────────┘
▼ │
┌──────────────────────┐ ▼
│ Enrichment Service │ ──► [ GPU Fleet: Embedding Model ]
│ (NER, Embeddings) │
└───────────┬──────────┘
│
▼
┌──────────────────────┐
│ Kafka: enriched-arts │
└───────────┬──────────┘
│
│ REAL-TIME CLUSTERING ENGINE
▼
┌──────────────────────┐ ┌─────────────────────┐
│ Online Clusterer ├─────►│ Vespa Vector DB │ (ANN Search over
│ (Greedy Matcher) │◄────┤ (Centroid Store) │ 72h centroids)
└───────────┬──────────┘ └─────────────────────┘
│
├──► Write to Cluster Store (Cassandra)
│
▼
┌──────────────────────┐ ┌─────────────────────┐
│ Kafka: cluster-events├─────►│ Offline Batch Fixer │ (Periodic HDBSCAN
└───────────┬──────────┘ │ (Over/Under Merge) │ Re-clustering)
│ └─────────────────────┘
│
│ READ & PERSONALIZATION PATH
▼
┌──────────────────────┐
│ Candidate Pool Builder
└───────────┬──────────┘
│
▼
┌────────────────────┐
│ Redis Pool Cache │
└──────────┬─────────┘
│
▼
┌──────────────────────┐ ┌─────────────────────┐
│ API Gateway │ ──► │ Ranking Service │ ◄── [ User Profile ]
└───────────┬──────────┘ │ (Two-Pass Scoring) │
│ └─────────────────────┘
▼
User
5. Ingestion & Deduplication Pipeline
- Fetching: Source crawlers poll RSS feeds and partner endpoints. Crawlers use HTTP
ETagandIf-Modified-Sinceheaders to prevent redundant payloads. - Canonical Normalization: Strip URL query strings, perform HTML sanitization, and calculate the canonical URL hash to determine the
article_id. - Exact & Near-Duplicate Filtering:
- Syndicated news services (e.g., AP, Reuters) often result in identical stories republished across multiple local news outlets.
- Calculate a 64-bit SimHash over document $n$-grams during ingestion.
- Perform Locality-Sensitive Hashing (LSH) lookup against a 72-hour sliding window of active article hashes.
- If an incoming article has a Hamming distance $d \le 3$ relative to an existing article, mark it as an exact duplicate child of the original article. It will not generate a new vector embedding or trigger clustering updates; it is simply attached to the existing article's metadata list.
6. Story Clustering Deep Dive
Grouping news articles requires a hybrid approach: online greedy assignment for real-time latency requirements, paired with offline batch re-clustering to fix structural errors (drift).
INCOMING ENRICHED ARTICLE
│
▼
┌─────────────────────────────────────┐
│ ANN Query: Top-20 Nearby Centroids │
│ (Filtered by Lang & 72h Window) │
└──────────────────┬──────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Hybrid Composite Scoring │
│ s = w1(Cos) + w2(Entity) + w3(Time) │
└──────────────────┬──────────────────┘
│
Is max(s) > Threshold τ?
├─── YES ───► Assign to Existing Cluster
│ (Update running centroid & entities)
│
└─── NO ────► Create New Cluster
(Publish initial centroid)
Step 1: Online Greedy Assignment
For every incoming non-duplicate article $A$:
- Embedding Generation: The text (title + first 3 paragraphs) is processed via a lightweight transformer model (e.g., MiniLM) to generate a 728-dim normalized embedding $\mathbf{v}_A$.
- Candidate Selection: Perform an Approximate Nearest Neighbor (ANN) search against current active cluster centroids ($\mathbf{c}_K$) created within the last 72 hours, using cosine distance. Retrieve the top $K=20$ candidate clusters.
- Composite Distance Calculation: Evaluate candidate clusters using a multi-feature similarity metric rather than raw cosine distance alone:
$$S(A, C) = w_1 \cdot \cos(\mathbf{v}_A, \mathbf{c}_C) + w_2 \cdot \text{Jaccard}(E_A, E_C) + w_3 \cdot \exp\left(-\frac{\Delta t}{\sigma}\right)$$
Where:
- $E_A, E_C$ represent named entity sets (people, organizations, locations) extracted via Named Entity Recognition (NER).
- $\Delta t$ is the difference between article publication time and cluster
first_seen_at. - Entity matching prevents distinct events involving similar entities from merging (e.g., "Company X acquires Company Y" vs. "Company X sues Company Y").
- Assignment Threshold:
- If $\max S(A, C) \ge \tau_{\text{assign}}$, assign $A$ to cluster $C$. Update cluster $C$'s running centroid:
$$\mathbf{c}_C^{(n+1)} = \frac{n \cdot \mathbf{c}_C^{(n)} + \mathbf{v}_A}{n + 1}$$
- If $\max S(A, C) < \tau_{\text{assign}}$, create a new cluster $C_{\text{new}}$ with $A$ as its seed member.
Step 2: Offline Correction (Addressing Merge Errors)
Greedy online clustering suffers from two primary errors over time:
- Under-Merging (Split Clusters): Two sources cover a breaking event simultaneously, generating two independent clusters before either centroid has stabilized.
- Over-Merging (Cluster Drift): A major ongoing topic (e.g., an election) swallows distinct sub-events over multiple days.
Correction Job: A Flink/Spark batch task runs every 15 minutes over the active 72-hour window:
- Runs hierarchical agglomerative clustering (HAC) or HDBSCAN over article embeddings inside shared topic categories.
- Cluster ID Preservation Rule: When merging Cluster $C_1$ and Cluster $C_2$, retain the
cluster_idof the cluster with the earlierfirst_seen_attimestamp. Create a pointer/alias mapping from the newercluster_idto the older one to preserve client bookmarking and active user session states.
7. Feed Generation & Personalization
Candidate Generation (Pass 1)
To handle 50,000 QPS, avoid running heavy deep-learning rankers across millions of items on every request. Maintain regional and topical Candidate Pools in Redis:
- Global Trending Pool: High cluster velocity (articles per minute).
- Topic Pools: Sorted by recency and global cluster authority score for categories like Technology, Politics, and Sports.
Scoring & Personalization (Pass 2)
When a user requests their feed, retrieve ~200 cluster candidates from relevant topic pools based on the user's affinity profile, then compute the final score for each cluster $C$:
$$\text{Score}(U, C) = \text{BaseScore}(C) \cdot \prod_{i} \text{Multiplier}_i$$
$$\text{BaseScore}(C) = (\text{Velocity}_C)^{0.5} \cdot \exp\left(-\frac{\text{Age}C}{\tau{\text{decay}}}\right)$$
$$\text{Multiplier}_{\text{topic}} = 1 + \gamma \cdot \text{Affinity}(U, \text{Topic}C)$$ $$\text{Multiplier}{\text{diversity}} = \text{Penalty for repeating recent sources/topics in current page}$$
Caching & Pagination Mechanics
- Cursor Construction: To prevent duplicate items or missing entries as clusters re-rank, encode the feed generation timestamp and offset into an opaque cursor token:
Cursor = Base64( SnapshotTimestamp || PageOffset || Hash(UserId) )
- If
SnapshotTimestampis less than 5 minutes old, retrieve the ordered candidate cluster IDs directly from the user's cached snapshot key in Redis (user:feed:<user_id>:<snapshot_ts>).
8. Reliability, Edge Cases & Bottlenecks
1. Breaking News Surge (Backpressure Management)
- Problem: A major world event produces tens of thousands of articles per minute, causing vector index lock contention and embedding worker lag.
- Mitigation: Rate-limit crawler intake per publisher. Route high-authority feeds (e.g., major wire services) to a high-priority Kafka topic, while placing low-tier blogs in a low-priority queue. If ingestion lag exceeds threshold limits, dynamic routing skips deep transformer vector generation and falls back to entity-only matching.
2. Poison Pill / Hot Key Clusters
- Problem: A massive cluster accumulates thousands of underlying articles, causing latency spikes when fetching cluster details (
GET /v1/clusters/{id}/articles). - Mitigation: Cap the maximum number of indexed child articles per cluster at 200 in the primary datastore. Move remaining overflow articles to secondary cold storage (S3), accessible only via explicit paginated historical search queries.
3. Monitoring & Quality Metrics
- Pairwise Cluster Precision & Recall: Sample human-labeled pairs daily to verify that merged articles refer to the exact same event.
- Cluster Velocity Anomaly Detection: Alert if a single cluster absorbs $> 10%$ of all incoming pipeline throughput, indicating an aggressive over-merging issue (low threshold $\tau_{\text{assign}}$).