Design a Personalized Article Feed Backed by Publisher APIs
System DesignModel answerLast updated
Design a system that continuously pulls article metadata from third-party publisher APIs and serves each user a ranked, paginated feed based on the publishers and categories they follow.
The Problem
You are designing a content aggregation platform. The service fetches article metadata — title, summary, category, and source URL — from dozens of third-party publisher APIs and assembles a personalized feed for each user. The platform never hosts article text; clicking an article sends the reader to the publisher's site.
Users express relevance by explicitly following publishers and categories. The feed shows the most recent articles from those subscriptions, paginated for infinite scroll.
Constraints to Keep in Mind
- Traffic numbers are yours to estimate. Derive ingestion volume and read QPS, then use each number to justify a specific decision or to explain why an optimization is not yet warranted.
- Publisher APIs are outside your control. They may rate-limit you, go silent, respond slowly, or use different pagination styles (cursor-based, timestamp-filtered, or plain page numbers).
- Storage holds only metadata, not article bodies.
Useful Clarifying Questions
- How current must the feed be? Is a five-minute lag acceptable, or do users expect near-real-time delivery?
- How far back can a user scroll — 24 hours of articles, 30 days, unlimited?
- Can one article carry multiple categories, and how does that affect deduplication in a feed?
- What happens to a user's feed while a publisher they follow is down?
Part 1 — Fetching and Storing Articles
Design the ingestion layer that keeps article metadata fresh.
Cover:
- A scheduler and worker architecture, with per-publisher state so each publisher's progress is tracked independently.
- How frequently each publisher is polled, and how a single polling run decides it has seen everything new and can stop.
- Idempotent writes so that fetching the same article twice does not create a duplicate record.
- Behavior under rate limiting, timeouts, and extended outages — including how you detect a publisher that has gone silent without returning errors.
Part 2 — Assembling and Serving the Feed
Design the read path that produces a user's paginated feed.
Cover:
- The data model for articles, categories, and user subscriptions.
- How newly ingested articles reach a user's feed — push (fan-out on write) versus pull (merge on read) — and your reasoning for whichever you choose.
- Deduplication when an article appears in multiple followed categories or publishers.
- Stable pagination: a user who closes and reopens the app sees a consistent feed, not a shifted one.
- How you bound storage for lists that could otherwise grow without limit, backed by the capacity estimate you computed.
Hints
Hint 1
Start with a back-of-envelope estimate before touching the design. Assume ~500 publishers each publishing ~50 articles per day. That is ~25,000 articles/day globally, which is modest — let that number guide how aggressively you need to optimize.
Hint 2
For ingestion, think about what state each polling worker needs to persist. A last-fetched cursor or high-water timestamp stored per publisher lets you resume after a crash without re-scanning everything. That same state is what makes writes idempotent.
Hint 3
For the feed read path, decide early whether to fan out articles to follower feeds on write or to merge lists on read. Fan-out is fast to read but expensive to write at scale; merge-on-read is cheap to write but requires a heap-merge at read time. The right answer depends on subscriber count and read/write ratio — reason through it explicitly rather than picking one by default.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
What a Strong Answer Looks Like
Functional Requirements (Nail These First)
- Ingest article metadata (title, summary, category, URL, published timestamp) from publisher APIs.
- Serve each user a feed of articles from publishers and categories they follow, sorted by recency.
- Support paginated infinite scroll with a stable cursor.
- No article body storage; all reads of full content go to the publisher.
Capacity Estimate
Start here, because every architectural decision should reference a number.
- Publishers: ~500, each publishing ~50 articles/day → ~25,000 articles/day ingested globally.
- Users: assume 10 million, each following ~10 publishers/categories on average.
- Read traffic: news apps are read-heavy. Assume each user opens the app twice a day → ~20 million feed requests/day → ~230 reads/second at steady state, with a 5–10× peak → ~1,500 reads/second peak.
- Storage: 25,000 articles/day × ~1 KB metadata each = 25 MB/day. Even keeping two years of history, that is under 20 GB. A single Postgres instance handles this comfortably — no exotic storage layer needed.
State this explicitly: "The ingestion volume is small enough that a modest fleet of workers is sufficient. The read volume is moderate — caching at the feed layer matters, but sharding the article store is premature."
Part 1 — Ingestion Pipeline
Scheduler and Workers
Use a central scheduler (a cron-like service or a message queue with delayed delivery) that emits a polling job per publisher on a configurable interval. Workers pull jobs from the queue, fetch new articles, and write metadata.
Polling frequency: There is no single right answer, but it should be proportional to publisher activity. A tier system works well:
- Active publishers (>20 articles/day): poll every 5–10 minutes.
- Low-volume publishers: poll every 30–60 minutes.
- Start with a flat interval (e.g., 15 minutes for all) and tune from metrics.
Each worker persists a per-publisher cursor — either a timestamp of the last successfully ingested article or a pagination cursor returned by the API — to a durable store (Redis or a DB row). On the next run, the worker starts from that cursor.
Stop Condition
A polling run stops when one of these is true:
- The API returns a page with no articles newer than the stored cursor.
- The API signals the last page explicitly.
- A safety cap (e.g., 20 pages per run) is hit — log a warning if this triggers, as it may mean a cursor was lost.
Without a stop condition, a stateless worker would re-scan the entire history every run.
Idempotent Storage
Use a compound unique key on (publisher_id, article_url) or on a canonical article ID provided by the publisher. An upsert on that key means re-fetching an article updates the record rather than creating a duplicate. Never rely on title alone — publishers change headlines.
Handling Failures
- Rate limiting (HTTP 429): Respect
Retry-Afterheaders. Back off exponentially (e.g., 1s, 2s, 4s, cap at 5 minutes) and requeue the job. Isolate publishers: one throttled publisher does not block workers processing others. - Timeouts / 5xx: Retry with backoff up to three times, then mark the publisher as degraded and alert.
- Silent failure (no errors but no new articles): This is the tricky case. Track
last_successful_fetch_atper publisher. If a publisher has not produced a new article in N hours (set a threshold based on their normal cadence), fire a low-severity alert so an operator can check manually. Do not auto-disable a publisher — they may just be on a news-slow day.
Part 2 — Feed Assembly and Serving
Data Model
articles
article_id UUID PK
publisher_id FK
url TEXT UNIQUE
title TEXT
summary TEXT
published_at TIMESTAMPTZ
categories TEXT[] -- e.g. ["politics", "world"]
user_follows
user_id UUID
entity_type ENUM('publisher', 'category')
entity_id TEXT
PRIMARY KEY (user_id, entity_type, entity_id)
Push vs Pull for Feed Assembly
This is the key trade-off. Reason through it before committing:
Fan-out on write (push): When an article is ingested, write a row to a user_feeds table for every follower of the relevant publisher and categories. Reads become a simple single-table scan — fast. But a popular category with 1 million followers means 1 million writes per article. At 25,000 articles/day, that is 25 billion writes/day at worst-case fan-out. Too expensive without a purpose-built fan-out infrastructure.
Merge on read (pull): At request time, look up the user's followed publishers and categories, fetch the most recent N articles per entity, merge and deduplicate them server-side. Reads are more expensive but writes are free. At 1,500 reads/second and ~10 followed entities per user, each read requires ~10 small index scans and a merge. This is manageable — especially with a per-user feed cache (TTL: 1–2 minutes).
Recommendation: Start with merge-on-read, cache aggressively, and revisit fan-out only if read latency becomes a problem. The article volume is low enough that the merge is cheap.
Deduplication
An article tagged with both "politics" and "world" should appear once in a feed that follows both categories. Use the article_id as the deduplication key during the server-side merge: load candidates from all followed entities, deduplicate by article_id, then sort by published_at DESC.
Stable Pagination
Use a cursor-based approach: the cursor encodes (published_at, article_id) of the last seen article. The next-page query is:
WHERE (published_at, article_id) < (:cursor_ts, :cursor_id)
ORDER BY published_at DESC, article_id DESC
LIMIT 20
This is stable even if new articles are ingested between pages, because the cursor anchors to a specific point in the ordering. Offset-based pagination (LIMIT 20 OFFSET 40) breaks when new rows are inserted — articles shift positions between pages.
Bounding Storage
Articles are small (~1 KB each) and ingestion volume is low (~25 MB/day). A 90-day retention policy covers almost all realistic scroll depth and caps storage at ~2.25 GB for article metadata. Archive or delete older rows with a background job. If a user requests articles older than the retention window, return an empty page with a end_of_history flag.
Common Mistakes to Avoid
- Polling all publishers at the same fixed interval regardless of activity — wastes requests on quiet publishers and misses bursts from active ones.
- Forgetting the silent-failure case: a publisher that stops responding without errors will look healthy unless you monitor
last_successful_fetch_at. - Using offset pagination — it produces duplicate or skipped articles when new items arrive mid-scroll.
- Conflating deduplication of articles across categories with deduplication of publisher feed entries — handle both at the merge step with a single
seen_article_idsset. - Over-engineering fan-out before measuring whether merge-on-read with caching is already fast enough.