KatInterview

Topic-Based Article Aggregator: Crawling, Dedup, and Feed Serving

System DesignModel answer
MediumModel answerSystem Designsystem-designschedulingdeduplication

Last updated

Design a service that polls tens of thousands of external publishers, stores articles without duplicates, and serves topic timelines with stable pagination under 50ms p99.

Problem

You are asked to design a content aggregation backend. It regularly fetches articles from outside publishers (RSS/Atom feeds and news APIs), assigns each article to one or more topics, keeps them durably, and lets clients read a per-topic timeline, newest first.

Functional requirements

  • Polling: Pull from tens of thousands of sources, each on its own cadence (roughly every 5 to 60 minutes), without exceeding what each source permits.
  • Safe re-ingestion: Retried jobs and publishers that re-emit old items must never create duplicate articles.
  • Topics: An article can belong to several topics out of a fixed catalog (for example payroll, benefits, compliance).
  • Timeline reads: Clients fetch a topic's articles in reverse chronological order, with pagination that neither repeats nor skips items while new articles keep arriving.

Non-functional requirements

  • p99 latency below 50 ms for topic reads.
  • No loss of an article once it has been accepted. Reads must be highly available.
  • A slow or broken publisher must not be able to consume the capacity needed by healthy ones.

Scale

DimensionValue
Registered sources50,000
New articlesabout 5M/day (about 60/s average, about 300/s peak)
Retained dataabout 100M articles over 12 months
Topic read traffic10,000 QPS
Topicsabout 500; the top 20 take about 80% of reads

What to cover

  1. The read API, including pagination.
  2. How fetches are scheduled, dispatched, and rate-limited across many workers.
  3. Storage schema, indexes, and the keys used to make writes idempotent.
  4. How the read path meets 10k QPS and the latency target, including the cache layout and cursor design.
  5. The main trade-offs: freshness against latency, write amplification from per-topic indexing, and cursor versus offset pagination.

Hints

Hint 1

Do the arithmetic first: 50k feeds at about 15 minute intervals is only about 55 fetches/s, and 5M articles/day is a small write rate. The hard parts are unreliable third parties, idempotency, and a skewed read load, not raw throughput.

Hint 2

For dedup, think in layers: a canonical URL hash, a per-source GUID, and a content hash to tell a real edit from a harmless re-publish. Make the write an upsert so at-least-once delivery is safe everywhere upstream.

Hint 3

For pagination, use a cursor made of (published_at, article_id) so the order is total and ties are broken deterministically. Use the same ordering in the cache (a sorted set per topic) and in the database fallback query so both give identical pages.