Designing a News Aggregator (Google News / Apple News)

Difficulty: Intermediate Topics: Crawling, natural language processing (NLP) Deduplication, Feed Ranking, Trending Detection, Caching Asked at: Google, Amazon, Microsoft, Apple, Flipkart · Prerequisites: Caching, Message Queues, and Database Indexing


1. Understanding the Problem

A news aggregator continuously collects articles from thousands of publishers around the world, removes duplicates (50 sources might cover the same event), ranks them by relevance and freshness, and serves personalized feeds to millions of users. The hard parts: ingesting content from unreliable sources at scale, detecting that 200 articles are about the same event, handling breaking news spikes (traffic 10x during elections or disasters), and personalizing without a cold-start problem.
💡 Cold start = a brand-new user has no reading history, so there is nothing to personalise from. Whatever you show them in that first session decides whether they ever generate the signal you needed.

Real examples: Google News (aggregates from 50K+ sources), Apple News, Flipboard, Inshorts, Microsoft Start.


2. Naive First Cut

flowchart LR
    CRAWLER["Crawler"]
    DB[("Single DB<br/>all articles")]
    USER["User"]

    CRAWLER --> DB
    USER --> DB

Crawl RSS feeds periodically, dump articles into a database, serve them sorted by time.
💡 RSS (Really Simple Syndication) is a standard XML file a publisher keeps at a fixed URL listing their latest articles. It is the cheap path: fetch one small file instead of scraping the whole site.

Why this breaks:

  • No deduplication - same story from 50 sources clutters the feed
  • No personalization - everyone sees the same feed regardless of interests
  • Crawling 50K sources sequentially takes hours - stale news
  • Breaking news takes too long to surface (waiting for next crawl cycle)
  • Single DB can’t handle 100M+ articles + millions of feed queries
  • No concept of “topics” or “stories” - just a flat list of articles

3. Prior Art We’re Drawing From

  • Google News Clustering - Groups articles about the same event into “story clusters” using NLP similarity. A story cluster has one headline, multiple source links, and a freshness score that decays over time. (Google Blog)
  • Facebook News Feed Ranking - Multi-stage ranking pipeline: candidate generation (1000s) → lightweight ranker (100s) → heavy ranker (top 50). Balances engagement prediction with content quality signals. (Facebook Engineering)
  • Twitter Trends Detection - Detects trending topics by comparing current mention velocity against historical baseline. A topic “trends” when its current rate exceeds the expected rate by a statistical threshold, not just when volume is high. (Twitter Engineering)
  • Apache Kafka + Flink at LinkedIn - Real-time content processing pipeline that ingests millions of events, enriches them, deduplicates, and routes to multiple downstream consumers (feed, notifications, search index). (LinkedIn Engineering)

4. Functional Requirements

Core (Top 3)

  1. Ingest articles from thousands of sources - continuously crawl/receive articles from 50K+ publishers via RSS, APIs, and webhooks
  2. Deduplicate and cluster - group articles about the same event into story clusters, surface the best source as the headline
  3. Serve personalized feed - each user sees a ranked feed based on their interests, reading history, and location

Below the Line

  • Breaking news push notifications
  • Topic following and custom sections
  • Publisher credibility scoring
  • Fact-check labels
  • Offline reading / save for later
  • Comments and social sharing

5. Non-Functional Requirements

NFR Target
Freshness Breaking news appears within 2-5 minutes of first publication
Scale 50K sources, 1M+ new articles/day, 100M+ DAU (daily active users)
Feed latency Personalized feed served in < 200ms P99 (the delay 99% of requests beat)
Availability 99.99% - news is time-sensitive, downtime means missed events

Below the Line

  • Multi-language support (50+ languages)
  • Regional content laws compliance (right to be forgotten)
  • Publisher analytics dashboard

6. Scale Estimation (Back-of-Envelope)

  • Sources: 50K publishers, crawled every 5-15 minutes
  • Ingestion: ~1M new articles/day, 10K/hour average, 50K/hour during breaking events
  • Storage: ~500GB new article content/month (title + body + metadata), 5TB with media links
  • Read QPS: 50K feed requests/sec at peak (100M DAU x 5 opens/day / 86400)
    💡 QPS = queries per second. Dividing a daily total by 86,400 seconds gives the average; news traffic is savagely peaked, so the number that matters is the worst minute, not the average. Learn more →
  • Story clusters: ~50K active clusters at any time, 500K total/month

7. Core Entities

  • Article - URL, title, body, publisher, publish time, language, category, media
  • Publisher - name, domain, credibility score, crawl frequency, RSS/API endpoint
  • Story Cluster - a group of articles about the same event, with a representative headline, summary, source count, and freshness score
  • Topic - a category or tag (Politics, Tech, Sports, etc.) that stories belong to
  • User Profile - interests (topics followed), reading history, location, language preferences

8. API / System Interface

GET /v1/feed?userId={id}&page={n}
  Response: [{ storyCluster: { headline, summary, sources[], topic, publishedAt, imageUrl } }, ...]

GET /v1/story/{clusterId}
  Response: { headline, summary, articles: [{ title, publisher, url, publishedAt }], relatedStories[] }

GET /v1/topics
  Response: [{ id, name, articleCount }]

GET /v1/trending
  Response: [{ storyCluster, velocity, region }]

POST /v1/user/interests
  Body: { topics: ["tech", "sports"], publishers: ["bbc", "reuters"] }
  Response: 200 OK

Security note: Feed is read-only for users. Article ingestion is internal only (no user-submitted content). Rate-limit feed API to prevent scraping.


9. High-Level Design

FR1: Ingest Articles from Thousands of Sources

The first challenge: 50K publishers, each publishing 10-100 articles/day. We need to crawl them continuously, extract content, and store it. Some publishers offer RSS feeds, some have APIs, some need HTML scraping. Sources are unreliable - they go down, change formats, or throttle us.

New components:

  1. Crawl Scheduler - walks the full source list on a fixed interval and dispatches every source to be crawled. One interval for everybody.
  2. Crawler Workers - stateless workers that fetch content from assigned URLs. Handle retries, rate limiting per publisher, and format parsing (RSS, Atom, HTML scraping).
  3. Content Extractor - parses raw HTML/RSS into structured data: title, body text, publish time, author, images. Strips ads and navigation.
  4. Article Store (Cassandra) - stores all articles durably. Partitioned by publish date for efficient time-range queries.
  5. Kafka - decouples crawling from downstream processing. Crawlers publish raw articles; multiple consumers process them independently.
flowchart LR
    SCHED["Crawl Scheduler<br/>fixed interval"]
    WORKERS["Crawler Workers<br/>stateless pool"]
    EXTRACT["Content Extractor"]
    KF["Kafka<br/>raw articles"]
    STORE[("Article Store<br/>Cassandra")]
    SOURCES["50K Publishers"]

    SCHED -->|"1"| WORKERS
    WORKERS -->|"2"| SOURCES
    WORKERS -->|"3"| EXTRACT
    EXTRACT -->|"4"| KF
    KF -->|"5"| STORE

Step-by-step flow:

  1. Crawl Scheduler starts a pass and takes the next source off the list — every source gets crawled on the same cycle
  2. Assigns it to a Crawler Worker (round-robin across the worker pool)
  3. Worker fetches the RSS feed or webpage, respecting robots.txt and rate limits
    💡 robots.txt is a file publishers put at the root of their site saying which paths crawlers may fetch and how fast. Ignoring it is how a crawler gets its IP range blocked by the sources it depends on.
  4. Content Extractor parses the raw content into structured article fields
  5. Deduplicates at the URL level (skip if we’ve already seen this exact URL)
  6. Publishes the new article to Kafka topic articles.raw
  7. Downstream consumers (clustering, indexing) read from Kafka independently

Why Kafka? Crawling speed varies wildly (some sources respond in 50ms, some in 5s). Kafka buffers the stream so downstream processing isn’t coupled to crawl speed. If the clustering service goes down for maintenance, articles queue up and are processed when it’s back.

What we have deliberately left broken. Articles from 50K publishers are being fetched, parsed and stored. The schedule is the problem, and it fails in both directions at once:

Every source is crawled on the same cycle, so we spend identical effort on Reuters and on a blog that posts twice a month. Do the arithmetic on a 5-minute cycle: 50K sources at ~2s average response time is 100K seconds of crawl work per pass, which needs ~333 workers running flat out just to finish inside the window, and the overwhelming majority of those fetches return nothing new.

Lengthen the interval to make it affordable and the other failure appears: a major story breaks, the first publisher posts it, and we do not look at that source for another 30 minutes. The product promise is breaking news, and the schedule is the thing deciding how late we are. Both halves are Deep Dive 2.


FR2: Deduplicate and Cluster Articles into Stories

This is the hardest part. When a major event happens (election results, earthquake), 200 publishers write about it within minutes. We need to detect that these 200 articles are about the same event and group them into one “story cluster.” The user should see one headline with “200 sources” - not 200 separate cards.

New components:

  1. Clustering Service - consumes articles from Kafka and decides whether each one belongs to a story we already know about.
  2. Story Cluster DB (Postgres) - stores cluster metadata: representative headline, source list, topic, freshness score, article count, and the significant keywords of the cluster.
flowchart LR
    KF["Kafka<br/>raw articles"]
    CLUSTER["Clustering Service"]
    CLUSTERDB[("Cluster DB<br/>Postgres")]
    STORE[("Article Store")]

    KF -->|"1. Process new article"| CLUSTER
    CLUSTER -->|"2. Read recent clusters"| CLUSTERDB
    CLUSTER -->|"3. Assign or create cluster"| CLUSTERDB
    CLUSTER -->|"4. Fetch article content"| STORE

Step-by-step flow:

  1. Clustering Service consumes a new article from Kafka
  2. It extracts the significant words from the title — dropping stopwords — and compares them against the keyword sets of clusters from the last 24 hours
    💡 Stopwords are the words too common to carry meaning — “the”, “of”, “and”. Dropping them is the first thing any text-matching scheme does, because otherwise every headline looks similar to every other one.
  3. Enough keywords in common? → Add the article to that cluster. Update its source count, freshness and representative headline
  4. No match? → Create a new cluster seeded with this article and its keywords
  5. Assign topics to the cluster from content classification (Politics, Tech, Sports)
  6. Update freshness: score = article_count * recency_weight — more sources and newer means hotter

Why cluster at all rather than show every article? Because 200 articles about one earthquake is not 200 pieces of news, and a feed that shows them as 200 cards is unusable. Collapsing them into one story with “200 sources” is the product.

What we have deliberately left broken. Articles do get grouped, and the grouping rule is the weakest part of the whole design.

Keyword overlap is a proxy for topic, not for event, and it fails in both directions. “Biden election victory” and “Biden election campaign funding” share almost every significant word and are different stories, so they merge — and a merged cluster is worse than two separate ones, because the headline we show is now about one thing and the sources are about another. Meanwhile “Biden wins election” and “US Presidential race results announced” are the same event and share no significant words at all, so they stay apart and the user sees the same story twice.

Neither failure is tunable away: raising the overlap threshold creates more duplicates and lowering it creates more bad merges. That is Deep Dive 1, and it is the hardest problem on this page.


FR3: Serve Personalized Feed

When a user opens the app, they need a ranked feed of story clusters tailored to their interests. A tech enthusiast in Bangalore should see different stories than a sports fan in Mumbai - even during the same news cycle.

New components:

  1. Feed Service - the API layer users hit. Fetches recent story clusters, filters to what the user cares about, returns the feed.
  2. User Profile Store (Redis) - stores each user’s interests, reading history (last 100 stories read), location, and language.
  3. API Gateway - the single front door for app traffic. It authenticates the caller, applies the anti-scraping rate limit the security note asks for, and routes to the Feed Service, so the Feed Service never has to do any of that itself.
flowchart LR
    USER["User"]
    GW["API Gateway"]
    FEED["Feed Service"]
    PROFILE[("User Profile<br/>Redis")]
    CLUSTERDB[("Cluster DB")]

    USER -->|"1. GET feed"| GW
    GW -->|"2. Forward to feed svc"| FEED
    FEED -->|"3. Load interests and history"| PROFILE
    FEED -->|"4. Read recent clusters by topic"| CLUSTERDB
    FEED -->|"5. Return newest first"| USER

Step-by-step flow:

  1. User opens app → GET /feed?userId=42
  2. Feed Service loads the user’s profile: subscribed topics, location, language, and the last 100 stories they read
  3. It queries the Cluster DB for recent clusters whose topics the user follows
  4. It filters out anything already in the reading history, so the feed does not repeat itself
  5. It sorts by publish time, newest first, and returns the top 50

Why filter on read history at all? Because a news feed that re-shows a story the user already opened is the fastest way to make it feel broken, and unlike ranking this is a correctness property rather than a quality one — it needs no model to get right.

What we have deliberately left broken. Users get a feed of recent stories in topics they chose, with nothing repeated. Two things are wrong, and they are independent:

  • Sorting by publish time is not ranking. The newest story is rarely the most important one, so a minor item published two minutes ago outranks an election result from twenty minutes ago. And because the only personalization is a topic filter, a user who follows Tech never sees a major political event at all — the filter has quietly become a wall. That is Deep Dive 3.
  • Every request rebuilds the feed from scratch. Normal traffic is 50K QPS and this does a profile read plus a cluster query plus a sort, per user, per request. During a breaking event traffic goes to 500K QPS while the same three stories dominate every single feed — so we do ten times the work to produce almost identical answers. That is Deep Dive 4.
    1. Return feed to user

Why cache feeds? At 50K feed requests/sec, running the ranking model on every request is expensive. Most users check their feed 5-10 times between updates anyway. A 5-minute cache means 99% of requests are served without computation.


10. Technology Choices

Tier Purpose Primary Pick Alternatives Why Primary Wins Here
Article Store Raw article content + metadata Postgres CockroachDB, MySQL, DynamoDB Relational queries for clustering joins; JSONB for flexible article metadata
Search Index Full-text article search + facets Elasticsearch Meilisearch, Typesense, Algolia Handles 10M+ docs with relevance scoring, geo, and NLP-based similarity
Event Bus Decouple crawler from pipeline Kafka Kinesis, Pulsar, RabbitMQ Ordered replay lets dedup and clustering workers process independently
Feed Cache Pre-computed personalized feeds Redis Memcached, DynamoDB DAX Sub-ms feed reads; sorted sets for time-decay ranking per user
Embedding Store Article vector embeddings for clustering pgvector or Pinecone Milvus, Weaviate, Qdrant pgvector keeps it in Postgres for small scale; Pinecone for dedicated vector search
Object Storage Article images and media links S3 GCS, MinIO, Azure Blob Cheap durable storage for crawled media assets

Why Elasticsearch over Postgres full-text search? With 1M+ articles/day and relevance-ranked queries across 50K sources, Postgres tsvector hits performance walls. Elasticsearch’s inverted index with BM25 scoring, faceted filtering, and horizontal sharding handles the read QPS and corpus size naturally.


11. Data Modeling

Postgres (Article Store — raw content and metadata):

CREATE TABLE articles (
    article_id UUID PRIMARY KEY,
    url VARCHAR(2000) UNIQUE NOT NULL,
    title VARCHAR(500),
    body TEXT,
    publisher_id UUID NOT NULL,
    published_at TIMESTAMP,
    language VARCHAR(5),
    category VARCHAR(50),
    content_hash VARCHAR(64),  -- dedup detection
    cluster_id UUID,           -- which story cluster this belongs to
    crawled_at TIMESTAMP NOT NULL
);
CREATE INDEX idx_articles_publisher ON articles(publisher_id, published_at DESC);
CREATE INDEX idx_articles_cluster ON articles(cluster_id);

CREATE TABLE story_clusters (
    cluster_id UUID PRIMARY KEY,
    headline VARCHAR(500) NOT NULL,
    summary TEXT,
    topic VARCHAR(50),
    source_count INTEGER DEFAULT 1,
    first_published_at TIMESTAMP,
    freshness_score DECIMAL(5,2),
    representative_image_url VARCHAR(500)
);

Redis (Feed Cache — personalized pre-computed feeds):

Key: "feed:{userId}" → Sorted Set (score = freshness_score, member = cluster_id)
Key: "feed:topic:{topicId}" → Sorted Set (score = freshness_score, member = cluster_id)
TTL: 30 minutes (refreshed by feed builder pipeline)

Elasticsearch (Search Index — full-text article search):

Index: articles
  Fields: title (text), body (text), publisher (keyword), category (keyword),
          published_at (date), location (geo_point), embedding (dense_vector)
  Used for: user search, dedup detection (MoreLikeThis), clustering input

Access Patterns:

Query Data Source How
Load personalized feed Redis ZREVRANGE feed:{userId} 0 19 → top 20 cluster_ids → hydrate from cluster cache
Cluster articles (same event) Embedding Store Compute cosine similarity between new article embedding and recent cluster centroids
Browse topic Redis ZREVRANGE feed:topic:{topicId} 0 19
Search articles Elasticsearch BM25 full-text + time-decay boost + optional topic filter

How Article Clustering Works (Grouping Same-Event Stories):

  1. New article crawled → NLP service extracts embedding vector (BERT/sentence-transformers)
  2. Query pgvector/Pinecone: “find clusters with centroid similarity > 0.85 published in last 24h”
  3. If match found: assign article to existing cluster, update cluster summary and source_count
  4. If no match: create new cluster with this article as the seed, set headline = article title
  5. Feed builder periodically re-ranks clusters by freshness (time decay) × source diversity × user interest affinity
  6. Writes ranked cluster_ids into feed:{userId} sorted set in Redis

12. Deep Dives

1) Two headlines about one event share no words. How do you tell they are the same story?

Problem: 50 publishers write about the same event with different headlines, different angles, different details. We need to detect they’re the same “story” and group them.

Bad: the keyword overlap FR2 built. “Biden” AND “election” → same cluster. It fails in both directions and neither is tunable away: “Biden election victory” and “Biden election campaign funding scandal” are completely different stories sharing the same keywords.

Good: TF-IDF cosine similarity on article titles. Compute term-frequency vectors, compare cosine similarity. Threshold > 0.7 = same cluster. Works for obvious duplicates but misses paraphrased content (“Stock market crashes” vs “Wall Street sees worst day in a decade”).

Great: Sentence embeddings (BERT/sentence-transformers) + incremental clustering.
💡 An embedding turns a sentence into a list of numbers positioned so that texts meaning the same thing sit close together, even with no words in common. That is the property keyword overlap could never have.

  1. Each article’s title + first paragraph → 768-dim vector via a pre-trained model
  2. New article’s vector compared against all active cluster centroids using approximate nearest neighbor (FAISS or Redis Vector Search)
    💡 A centroid is the average position of everything already in a cluster — the cluster’s “middle”. Comparing against centroids instead of against every article keeps the cost flat as a story grows to 200 sources.
  3. If cosine similarity > 0.85 → assign to cluster. Update centroid as running average.
    💡 Cosine similarity measures the angle between two of those number lists, from 0 (unrelated) to 1 (identical direction). The 0.85 threshold is the dial that trades false merges against duplicate stories.
  4. If no match → new cluster.
  5. Clusters decay: if no new article joins for 24h, cluster moves to archive.

Latency: Embedding generation ~10ms (GPU), ANN search ~5ms, total clustering decision < 20ms per article. At 10K articles/hour, one machine handles it.


2) How often do you crawl 10,000 sources that publish on no schedule?

Problem: A major event happens. The first publisher posts about it. Our crawler might not check that source for another 10 minutes. By then, users have already seen it on Twitter.

In simple terms: Breaking news just happened. If we wait for our next scheduled crawl (could be 10 minutes), users see it on Twitter first. We need to detect and surface breaking news faster.

Bad: the fixed interval FR1 built — crawl all 50K sources every 5 minutes. At 50K sources with 2s average response time, that’s 100K seconds of crawl time / parallelism. Even with 100 workers = 1000 seconds per full cycle. Too slow and wasteful for sources that rarely update.

Good: Adaptive crawl frequency. Track how often each source publishes. BBC publishes every 2 minutes → crawl every 3 min. A local blog publishes weekly → crawl every 6 hours. Prioritize sources by historical freshness.

Great: Adaptive crawling + webhook push + velocity detection.

  1. Push for top publishers: Major publishers (Reuters, AP, BBC) send webhooks when they publish. Instant - zero crawl delay.
    💡 A webhook inverts the direction: instead of us asking “anything new?”, the publisher calls our URL the moment they post. It removes the polling interval entirely, which is why it is reserved for the sources where seconds matter.
  2. Adaptive polling for the rest: Crawl frequency = f(publish_rate). High-velocity sources crawled every 3-5 min, low-velocity every 1-6 hours.
  3. Velocity spike detection: If the clustering service sees 10+ new clusters created in the last 5 minutes (unusual), trigger an emergency re-crawl of all top-100 sources. Something big is happening.
  4. Breaking news flag: Stories with cluster growth rate > 20 articles/hour get flagged as “Breaking” and boosted to the top of all feeds regardless of personalization.

3) A topic filter is a wall. How do we personalize without hiding the election?

Problem: Pure personalization creates filter bubbles - a user who reads only tech news never sees important political events. Pure chronological is noisy - most stories aren’t relevant to any specific user.
💡 A filter bubble is what you get when the system only ever shows you more of what you already clicked. Here it is not an accident of a model — FR3 built it as a literal topic filter.

In simple terms: If we only show you tech news because you read tech news, you’ll never learn about important political events. But showing everything is noisy. We need balance.

Bad: FR3’s topic filter plus a publish-time sort. Two failures in one: the newest story outranks the most important one, because recency is the only signal in the ordering; and the topic filter is absolute, so a user who follows Tech is structurally incapable of seeing a major political event. The filter bubble here is not an emergent property of a ranking model — we built it directly, as a WHERE clause.

Good: Topic-based filtering. User follows “Tech” and “Sports” → only show stories with those topics. Simple but misses cross-topic stories the user might care about and provides no ranking within a topic.

Great: Multi-signal scoring with diversity constraints.

Scoring formula per story cluster for a user:

score = 0.3 * topic_relevance
      + 0.25 * freshness_decay
      + 0.2 * story_importance (source_count * authority_avg)
      + 0.15 * engagement_signals (CTR from similar users)
      + 0.1 * diversity_bonus (penalize 3rd story on same topic)

💡 CTR means click-through rate: of the people shown this story, the fraction who opened it. It is a proxy for interest, and using it from “similar users” rather than from this one user is what gives a new reader a sensible feed before they have clicked anything.

Diversity constraint: After ranking, apply a post-processing pass:

  • No more than 2 consecutive stories from the same topic
  • At least 1 “serendipity” story per page (topic the user doesn’t usually read, but is nationally important)
  • Breaking news always ranks in top 3 regardless of personalization

Cold start (new users): Use location + language to serve a “trending in your region” feed. After 10 clicks, enough signal to personalize.


4) Traffic jumps 10x and every one of them wants the same three stories. What breaks?

Problem: Normal traffic is 50K QPS. During election night or a natural disaster, traffic spikes to 500K QPS in minutes. The same 3 stories are requested by everyone simultaneously.

In simple terms: Election night. Traffic spikes 10x in minutes. Everyone wants the same 3 stories. If we recompute the feed for each user, the system melts.

Bad: FR3 rebuilds every feed from scratch on every request — a profile read, a cluster query and a sort, per user, per request, with nothing cached. At 500K QPS that melts.

The detail that makes it galling is in the problem statement: during a breaking event the same three stories dominate every feed. So traffic rises tenfold at exactly the moment the answers become most similar to each other, and we respond by computing each one independently. Peak load and maximum redundancy arrive together.

Good: Feed cache with a 5-min TTL (time-to-live) absorbs most reads. But during breaking news, users want the LATEST - a 5-min-old cache feels stale.
💡 Time-to-live is how long a cached answer is allowed to be reused before it is thrown away. Every cache decision here is really a choice about how stale a feed may be. Learn more →

Great: Tiered caching + push invalidation.

  1. Global trending cache: Top 10 stories for each region, updated every 30 seconds. Served to users whose personal feed cache is stale. Super cheap (one cache entry per region, millions of reads).
  2. Breaking news override: When a story is flagged “Breaking,” it’s injected at the top of ALL cached feeds without regenerating the entire feed.
  3. Graceful degradation: If ranking service is overloaded, fall back to the global trending feed + user’s topic preferences (simple filter, no ML ranking). “Good enough” feed in 5ms vs perfect feed timing out.

13. Design Self-Audit

Question Answer
Single points of failure? Kafka is replicated. Crawlers are stateless. Cluster DB has read replicas. Feed cache is Redis Cluster.
Stale content? Feed cache TTL = 5 min. Breaking news bypasses cache. Acceptable for a news feed.
Duplicate articles? URL-level dedup at ingestion + semantic clustering catches paraphrases.
Hot stories? Trending cache absorbs 95% of reads for popular stories.
Publisher goes down? Crawler retries with backoff. Missing one crawl cycle is acceptable.

14. Core Flows

Flow 1: Article Ingestion (Breaking News)

sequenceDiagram
    participant S as Crawl Scheduler
    participant W as Crawler Worker
    participant E as Extractor
    participant K as Kafka
    participant C as Clustering Service
    participant DB as Cluster DB

    S->>W: Crawl bbc.com/rss (high priority)
    W->>W: Fetch RSS, find 3 new articles
    W->>E: Parse article content
    E-->>K: Publish to articles.raw
    K->>C: Consume new article
    C->>C: Generate embedding
    C->>C: Find matching cluster (cosine > 0.85)
    alt Cluster exists
        C->>DB: Add article to cluster, update freshness
    else New story
        C->>DB: Create new cluster
    end

Non-obvious failure: If the Clustering Service is slow during a breaking news spike (100 articles/min about the same event), articles queue in Kafka. This is fine - Kafka handles backpressure naturally. The feed might show the story 30-60 seconds later than ideal, but no data is lost.
💡 Backpressure = what happens when a downstream stage cannot keep up. A durable log absorbs the excess on disk and the consumer catches up later, instead of the overflow being dropped or crashing something.

Flow 2: Personalized Feed Load

sequenceDiagram
    participant U as User
    participant F as Feed Service
    participant Cache as Feed Cache
    participant R as Ranking Service
    participant P as User Profile
    participant DB as Cluster DB

    U->>F: GET /feed
    F->>Cache: Check cache for user:42
    alt Cache hit (< 5min old)
        Cache-->>F: Cached feed
        F-->>U: Return feed (sub-10ms)
    else Cache miss
        F->>R: Rank stories for user:42
        R->>P: Get interests + history
        R->>DB: Get top 500 active clusters
        R->>R: Score and rank
        R-->>F: Top 50 clusters
        F->>Cache: Store (TTL 5min)
        F-->>U: Return feed
    end

15. Final Architecture

flowchart TD
    SOURCES["50K Publishers"]
    SCHED["Crawl Scheduler"]
    WORKERS["Crawler Pool"]
    KF["Kafka"]
    CLUSTER["Clustering Service"]
    EMBED[("Embeddings<br/>Redis Vectors")]
    CLUSTERDB[("Cluster DB<br/>Postgres")]
    ARTICLES[("Article Store<br/>Cassandra")]
    FEED["Feed Service"]
    RANK["Ranking Service"]
    CACHE[("Feed Cache<br/>Redis")]
    PROFILE[("User Profiles<br/>Redis")]
    USER["Users"]
    GW["API Gateway"]

    SOURCES -->|"Provide articles"| WORKERS
    SCHED -->|"Trigger crawl"| WORKERS
    WORKERS -->|"Publish parsed article"| KF
    KF -->|"Process new article"| CLUSTER
    KF -->|"Sink data"| ARTICLES
    CLUSTER -->|"Compute embeddings"| EMBED
    CLUSTER -->|"Read cluster centroids"| CLUSTERDB
    USER -->|"GET personalized feed"| GW
    GW -->|"Forward to feed svc"| FEED
    FEED -->|"Lookup cached feed"| CACHE
    FEED -->|"Score and rank articles"| RANK
    RANK -->|"Read top clusters"| CLUSTERDB
    RANK -->|"Load user preferences"| PROFILE

How it works end-to-end (ingestion path):

  1. Crawl Scheduler triggers workers — adaptive scheduling pings 50K publishers at their optimal frequency
  2. Crawler Pool fetches articles — downloads, parses, and deduplicates new content
  3. Kafka receives raw articles — events streamed to downstream consumers
  4. Clustering Service groups stories — computes sentence embeddings, finds nearest neighbors, assigns articles to story clusters
  5. Article Store persists content — Cassandra stores full article text and metadata

How it works end-to-end (read path):

  1. User requests feed — hits API Gateway, routed to Feed Service
  2. Feed Cache checked — Redis returns cached personalized feed (5-min TTL absorbs 99% of reads)
  3. Cache miss triggers ranking — Feed Service calls Ranking Service which scores clusters by freshness, personalization, and diversity
  4. Ranking Service reads context — pulls story clusters from Postgres Cluster DB and user preferences from Redis Profiles
  5. Ranked feed returned — top stories served to the user with source diversity constraints applied

Key Technologies

Term What it is
Sentence Embeddings ML models (BERT, sentence-transformers) that convert text into fixed-size vectors capturing semantic meaning. Similar texts have high cosine similarity.
Approximate Nearest Neighbor (ANN) Algorithms (FAISS, HNSW) that find similar vectors without comparing against all vectors. O(log N) vs O(N).
Story Clustering Grouping articles about the same event. The cluster has one headline, N sources, a freshness score, and decays over time.
Adaptive Crawling Adjusting crawl frequency per source based on how often they actually publish. Saves resources, improves freshness for active sources.
Feed Ranking Multi-signal scoring that balances personalization, freshness, importance, and diversity to produce a ranked feed.
Cascade Ranking Two-stage: lightweight filter (1000→100) then expensive ML ranker (100→50). Saves compute.

What’s Expected at Each Level

Mid-level

Design the basic pipeline: crawl sources, store articles, serve chronologically. Propose RSS parsing and a database. With prompting, recognize the deduplication problem (same story from multiple sources). Propose keyword matching or URL-based dedup.

Senior

Proactively identify story clustering as the core challenge. Propose embedding-based similarity for grouping articles. Design the feed with personalization (topic preferences + freshness). Discuss adaptive crawl scheduling and why uniform polling wastes resources. Explain caching strategy for feed reads.

Staff+

Address breaking news latency (webhook push + velocity detection + emergency re-crawl). Discuss feed diversity constraints to avoid filter bubbles. Propose cascade ranking (lightweight filter → ML ranker) for cost efficiency. Cover graceful degradation during traffic spikes (fall back to trending feed). Discuss cold-start personalization and the tension between engagement optimization and editorial quality.


🎯 Key Takeaways

  • Story clustering with embeddings groups 200 articles about the same event into one card
  • Adaptive crawling balances freshness vs resource cost across 50K sources
  • Feed cache (5-min TTL) absorbs 99% of read traffic without re-ranking
  • Breaking news bypass injects urgent stories into cached feeds without full regeneration
  • Diversity constraints prevent filter bubbles while still personalizing


Understand the building blocks used in this design:

  • Message Queues → — pipeline crawled articles through fetch, parse, dedupe, and rank stages
  • Batch vs Stream → — batch crawling for coverage vs streaming for trending detection
  • Caching → — serves hot feeds and ranked stories fast
  • Bloom Filters → — cheaply skip already-seen article URLs during crawling and dedup