Google News
One publisher floods the pipeline with duplicates and oversized media.
Topic tools
Layout updated
Problem statement
Design a news feed like Google News. Collect articles from publishers and show readers a personalized list they can scroll through.
Functional requirements
- Fetch publisher articles and accept corrections or retractions.
- Remove duplicates, group related stories, and index articles.
- Serve and refresh a personalized feed with stable pagination.
- Fall back to a basic feed when personalization is unavailable.
Non-functional requirements
- Make new articles available within about 2 min.
- Keep duplicates and bad publishers from blocking healthy input.
- Aim for page under 250 ms.
- A stale feed is allowed; unauthorized content is not.
Back-of-the-envelope estimates
| Illustrative estimate |
|---|
| 50k publishers polled every 5 minutes ≈ 167 fetches/s |
| 5M articles/day × 2 KB metadata ≈ 10 GB/day |
| 100M users × 10 page reads/day ≈ 11.6k ; 5× peak ≈ 58k |
| 1M active sessions × 200 candidate IDs × 16 bytes ≈ 3.2 GB raw |
Entities
| Entity / logical owner |
|---|
| Article(articleId, publisherId, canonicalURL, contentHash, version, status) |
| Story(storyId, articleIds, clusteringVersion) |
| IndexDocument(articleId, version, locale, publishedAt) |
| Profile(userId, locale, interests, version) |
| FeedSnapshot(sessionId, viewerId, rankedIds, rankingVersion, expiresAt) |
| CandidateList(locale, category, generation, articleIds) |
API design
| Operation / input | Response and retry contract |
|---|---|
POST/publisher-events {publisherId, eventId, articleURL, version} | 202 after durable ingestion; signed webhook and replay protection. |
GET/articles/{id} | Canonical metadata/status and authorized media references. |
RETRACT {articleId, expectedVersion, reason} | canonical record and publish versioned removal intent. |
GET/feed?locale=en-US&limit=20 | Return items, snapshotId, freshness and signed nextCursor. |
GET/feed?cursor=... | Bind cursor to viewer/; reject expiry or offer explicit refresh. |
POST/feed/refresh | Create a new ranked ; do not mutate the old pagination order. |
High-level design
How to draw this design
- Collect articlesPublishers, intake service, and Kafka
- Process updatesArticle workers, story clustering, and change events
- Store and indexPostgreSQL, Elasticsearch, and regional candidate caches
- Serve the feedFeed service, candidate ranker, and session cache
Ingest and version articles, then project them into search and feed candidates. Save ranked IDs for stable paging.
- State ownership
- PostgreSQL owns the canonical article version and publication status.
- Scale
- Partition ingestion and reuse regional candidate lists across readers.
- Correctness
- Ignore older projection updates and verify retractions before serving affected articles.
- Failure and recovery
- Fall back to a basic feed when personalization is unavailable and ask expired cursors to refresh.
Publisher ingestion and indexing
Follow a publisher update until the article is stored and its search and feed projections can see the new version.
- Compute
- Messaging
- State
━━ Synchronous┄┄ Asynchronous···· Recovery / control▧ Fault
Each arrow is one interaction. Request, background and recovery branches are not one linear transaction.
Read the 11 flow steps
Personalized feed serving and pagination
Pick up at the regional article index. The feed service finds candidates, ranks them, and saves the result so later pages keep their order.
- Edge
- Compute
- State
━━ Synchronous┄┄ Asynchronous···· Recovery / control▧ Fault
Each arrow is one interaction. Request, background and recovery branches are not one linear transaction.
Read the 11 flow steps
High-level design component walkthrough
50K Publishers
RSS, webhook / , web crawling
Why, tradeoff and connected operations
Treat another system as a separate failure and retry domain with a documented contract.
Tradeoff: Feed quality and publisher outages vary
Connected operations: Pass validated input
Publisher Ingestion
Validate links and normalize metadata
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: Input validation adds ingestion work
Connected operations: Pass validated input; Publish event
Kafka: Publisher Intake Topic
Buffer spikes; isolate slow processors
Why, tradeoff and connected operations
Kafka retained partitioned stream. Key events by the domain ordering key; replay and independent consumers motivate this choice. rows remain in the source database; a relay publishes after commit. Buffer independent producers and consumers, with bounded and replay semantics.
Tradeoff: Queue lag consumes freshness budget
Connected operations: Publish event; Consume work
Processing Workers
Exact dedup, parse, safety checks
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: CPU-heavy enrichment creates backlog
Connected operations: Consume work; persist; thumbnails
PostgreSQL / Sharded Article DB
Authoritative article metadata; hash(articleId)
Why, tradeoff and connected operations
PostgreSQL owns article identity, metadata and publication state. Unique keys and transactions keep updates and downstream change intent consistent. suits canonical records; full-text retrieval is delegated to a search index.
Tradeoff: hot spots / eventual index lag
Connected operations: persist; Publish event
Object Storage + CDN
Serve thumbnail bytes independently
Why, tradeoff and connected operations
Object storage holds thumbnail bytes, and a serves nearby cached copies. This separates media bandwidth from article metadata traffic. Neither is the metadata database; remains responsible for article state.
Tradeoff: invalidation and egress charges
Connected operations: thumbnails
Kafka: Article Changes Topic
Reliable committed article events
Why, tradeoff and connected operations
Kafka retained partitioned stream. Key events by the domain ordering key; replay and independent consumers motivate this choice. rows remain in the source database; a relay publishes after commit. Buffer independent producers and consumers, with bounded and replay semantics.
Tradeoff: Consumers see events eventually
Connected operations: Publish event; index; group; update
Elasticsearch Article Index
By publisher, category, time, region
Why, tradeoff and connected operations
Elasticsearch indexes article text and filters for candidate retrieval. Its search structures support relevance queries without scanning the article database. Use a search index for discovery and for authority; this index can lag and be rebuilt.
Tradeoff: Write amplification and index lag
Connected operations: index
Story Clustering
Async group related items by storyId
Why, tradeoff and connected operations
Compute derived state away from request handlers; checkpoints and govern recovery.
Tradeoff: Semantic grouping is costly/imperfect
Connected operations: group; story event
Feed Materializer
Refresh shared category / breaking feeds
Why, tradeoff and connected operations
Compute derived state away from request handlers; checkpoints and govern recovery.
Tradeoff: Invalidation and rebuild spikes
Connected operations: update; story event; publish candidates
Redis / Shared Feed Caches
Hot category + global news candidates
Why, tradeoff and connected operations
Redis keeps hot category and regional candidate lists in memory. Shared lists reduce repeated search work across users. It is a derived cache, not another authoritative article database.
Tradeoff: Stale news until refresh/event
Connected operations: publish candidates
Web / Mobile Clients
Refresh creates new feed; scroll uses cursor
Why, tradeoff and connected operations
An application or user-facing endpoint starts or receives this flow.
Tradeoff: Refresh resets pagination
Connected operations: Submit request; images
Global Traffic Router
Healthy nearby region; failover with headroom
Why, tradeoff and connected operations
Centralize admission and routing while keeping business-state ownership downstream.
Tradeoff: Failover adds latency/load to peers
Connected operations: Submit request; Pass validated input
Regional API Gateway
Auth, limits, route to Feed Service
Why, tradeoff and connected operations
Centralize admission and routing while keeping business-state ownership downstream.
Tradeoff: Rate limits can impact burst reads
Connected operations: Pass validated input; GET /feed
Feed Service
Coordinate candidates, ranking, pages
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: Ranking can make unpredictable
Connected operations: GET /feed; lookup; hot candidates; miss / fallback; candidate set; 20 + cursor
PostgreSQL / User Profile DB
Interests, locale, preferences
Why, tradeoff and connected operations
PostgreSQL stores user interests and locale preferences. Indexed user lookups and transactional edits keep profile changes straightforward. fits durable user settings; derived feed candidates belong in separate serving stores.
Tradeoff: Privacy and dependency latency
Connected operations: lookup; features
Elasticsearch Article Index
Fallback candidates and metadata lookup
Why, tradeoff and connected operations
Elasticsearch retrieves articles by text and structured filters. It supplies fallback candidates when a shared cache misses. A search index suits discovery better than scanning rows, but canonical articles still live in PostgreSQL.
Tradeoff: Index replication lag affects freshness
Connected operations: miss / fallback
Candidate Ranker
Lightweight per-user ordering
Why, tradeoff and connected operations
Isolate this operation so it can scale and fail independently from storage.
Tradeoff: Compute cost; ranking volatility
Connected operations: candidate set; features; materialize active session
Redis: Session Snapshot Cache
Fixed ranked IDs and continuation cursor
Why, tradeoff and connected operations
Redis temporarily retains one session’s ranked IDs and cursor. Later pages can reuse that order without reranking everything. This is expiring pagination state, not a durable business record; expiry requires restarting the feed session.
Tradeoff: Per-session storage and expiry
Connected operations: materialize active session; 20 + cursor
Media CDN
Fast thumbnail delivery to clients
Why, tradeoff and connected operations
A serves nearby cached thumbnails and reduces repeated origin downloads. The underlying object store retains the original bytes. A is a delivery cache, not a second or database.
Tradeoff: Stale thumbnails and egress cost
Connected operations: images
Engineering control room
Deep dives — decisions, failures and recovery
Open a deep dive to follow the steps, try an example and see how recovery works.
Tradeoffs and alternatives
| Decision | Tradeoff / alternative and recovery implication |
|---|---|
| Separate duplicate articles from related stories | Story grouping can run later and be rebuilt after a model change. It should not rewrite which source articles were accepted. |
| Keep search and feeds repairable | Search may temporarily lag. Durable events let workers catch up or rebuild the index without inventing a missing source article. |
| Do not let one publisher stop everyone else | Fair limits may delay a busy publisher. Set freshness targets with those limits in mind and reserve capacity for healthy sources. |
| Keep the feed quick and pagination stable | storage adds memory and expiry handling. Cursor-only pagination works when the ordering stays stable for the session. |
| Propagate corrections and retractions | Invalidating a cache is fast when messages arrive on time. Checking authoritative status at serving time adds work but closes the gap for required removals. |
| Keep serving through a regional outage | Asynchronous copies keep the normal path fast but can lose recent writes when a whole region is lost. Cross-region durable acknowledgement costs latency and can reduce availability during a partition. |
Production scars & failure modes
One publisher floods the pipeline with duplicates and oversized media.
Look for: Measure lag and rejection rates by publisher, not just fleet totals.
Recovery and invariant: Enforce per-publisher budgets and payload limits, quarantine poison input and keep stable article/version identities through replay.
| Component / failure | Impact | Recovery mechanism | Alternative / tradeoff |
|---|---|---|---|
| Publisher unavailable | New material from that source stops; other sources should continue. | Back off with , retain source cursors and resume from confirmed watermarks. | Missing upstream content cannot be repaired by internal replication. |
| Processor crashes after DB commit | The same article may be delivered again. | with source identity/version and replay committed ; do not duplicate feed entries. | Dedup must cover supported replay. |
| Search index lost | Search/feed discovery becomes incomplete despite durable articles. | Rebuild into a new generation from canonical metadata, tail changes and swap after verification. | Rebuild competes for DB capacity; throttle it and expose index age. |
| Retraction arrives out of order | An older create could resurrect removed content. | Persist versioned tombstones and enforce version checks in index/feed consumers. | costs space but protects replay correctness. |
| Profile service unavailable | Personalized ordering cannot be computed safely within budget. | Serve nonpersonalized eligible regional candidates and identify freshness; circuit-break profile calls. | Do not use stale profile data for authorization decisions. |
| Shared cache lost | Many feed requests query the backing index at once. | list rebuilds, cap index concurrency and use last-known-good lists within policy. | Some responses become less fresh or smaller. |
| expired | The previous page order is no longer available. | Return an explicit refresh response; start a new with client dedup if desired. | Strong pagination continuity requires longer . |
| Region fails | Redirected readers may lose region-local snapshots. | Replicate snapshots if required, or return a controlled refresh while serving healthy-region candidates. | Preserving every session increases remote write cost. |
90-second interview summary
I would separate publisher ingestion from the reader request path. Pollers and incoming publisher events feed a durable queue. Workers normalize updates, assign stable article IDs, and commit canonical metadata and versioned publication work together. Search indexes and regional candidate lists consume those changes independently.
For reads, a regional feed service fetches a bounded set of locale, category, and interest candidates. It ranks them once per refresh and stores the ordered IDs for a short time. The cursor stays tied to that order, so page two does not skip or repeat an article just because its rank changed.
I would protect ingestion with publisher budgets, keep serving a basic feed when profiles are slow, and preserve retractions through versioned updates. Cached candidates can be stale, but the service verifies article status before serving removals or access restrictions.
During a regional outage, I would reroute reads where the required source state is available and resume publisher ingestion under a new fenced owner. The tradeoff is bounded feed staleness and occasional refreshes in exchange for fast regional reads and independent recovery.
Explain it without looking
Explain separate duplicate articles from related stories
Reveal answer
Recognize retries using article identity; group related reporting separately.
Two publishers covering the same event are not the same article. Merging them as exact duplicates can lose corrections and source history.
Story grouping can run later and be rebuilt after a model change. It should not rewrite which source articles were accepted.
Explain keep search and feeds repairable
Reveal answer
Record article changes and publication work together; apply only newer versions.
Writing the database and search index independently can leave them permanently different after a crash.
Search may temporarily lag. Durable events let workers catch up or rebuild the index without inventing a missing source article.
Explain do not let one publisher stop everyone else
Reveal answer
Set per-publisher fetch, size and processing limits.
One slow connection or oversized response can use the whole fetch pool if every publisher shares an unlimited budget.
Fair limits may delay a busy publisher. Set freshness targets with those limits in mind and reserve capacity for healthy sources.
Explain keep the feed quick and pagination stable
Reveal answer
Rank a small candidate set once, then paginate through the saved order.
Ranking the entire corpus is too slow and ranking again on page two can repeat or skip results.
storage adds memory and expiry handling. Cursor-only pagination works when the ordering stays stable for the session.
Explain propagate corrections and retractions
Reveal answer
Carry the canonical article version through indexing, candidate caches, and serving.
Messages can arrive out of order and a personalized can retain an article ID after it has been retracted.
Invalidating a cache is fast when messages arrive on time. Checking authoritative status at serving time adds work but closes the gap for required removals.
Explain keep serving through a regional outage
Reveal answer
Fail over serving and publisher intake independently using known replication progress.
A healthy feed server can still be backed by an index too far behind to honor required removals.
Asynchronous copies keep the normal path fast but can lose recent writes when a whole region is lost. Cross-region durable acknowledgement costs latency and can reduce availability during a partition.
Revision checklist
Revision checklist
- Reconstruct separate duplicate articles from related stories: Recognize retries using article identity; group related reporting separately.
- Reconstruct keep search and feeds repairable: Record article changes and publication work together; apply only newer versions.
- Reconstruct do not let one publisher stop everyone else: Set per-publisher fetch, size and processing limits.
- Reconstruct keep the feed quick and pagination stable: Rank a small candidate set once, then paginate through the saved order.
- Reconstruct propagate corrections and retractions: Carry the canonical article version through indexing, candidate caches, and serving.
- Reconstruct keep serving through a regional outage: Fail over serving and publisher intake independently using known replication progress.
- Name the authoritative state, boundary, retry identity and failure-domain durability guarantee.
- Explain one alternative and exactly which guarantee you would relax.
- Redraw the request and recovery paths without looking; mark what required a hint.
60-minute interview outline
60-minute interview walkthrough
| Time | Focus | What to cover |
|---|---|---|
| 0–5 min | Introductions | Introduce yourself briefly and confirm the interview format. |
| 5–15 min | Scope and scale | Scope publisher intake and reader feeds. Estimate article volume, feed reads, and freshness targets separately. |
| 15–30 min | High-level design | Trace an article into durable storage and the search projection. Then trace one regional feed request and its cursor. |
| 30–45 min | Deep dives | Explain versioned corrections and stable pagination. Choose where to check retraction or access status. |
| 45–55 min | Failure and recovery | Walk through a profile or serving region outage. Describe the fallback feed and how expired cursors are handled. |
| 55–60 min | Wrap-up | Summarize the design and its main tradeoff. Leave time for questions. |
On this page
- Problem statement
- Functional requirements
- Non-functional requirements
- Back-of-the-envelope estimates
- Entities
- API design
- High-level design
- High-level design component walkthrough
- Engineering control room
- Deep dives — decisions, failures and recovery
- Tradeoffs and alternatives
- Production scars & failure modes
- 90-second interview summary
- Explain it without looking
- Revision checklist
- 60-minute interview walkthrough