Build a Multi-Source Content Aggregation Platform
System DesignModel answerLast updated
Architect a system that collects content from diverse publishers, identifies user interests, and assembles personalized feeds with timely updates.
Design an aggregation platform that pulls content from multiple publishers and assembles customized feeds for readers based on their interests.
Readers can subscribe to categories and publishers. When someone joins without selecting preferences, they should see a sensible general selection. Time-sensitive content must reach all readers quickly when designated as urgent, without permanently displacing their personalization settings. Evaluate different feed assembly patterns and choose an approach that balances pre-computation with on-demand generation.
Requirements
- Content may appear from multiple publishers due to syndication
- Readers scrolling through results must see stable ordering even as new content arrives
- Reader preferences for categories and publishers will evolve over time
Important Clarifications
- What criteria determine urgent status and who controls that designation?
- What latency targets apply to regular content versus urgent updates?
- Should reader preferences completely hide content or simply deprioritize it?
Hints
Hint 1
Consider how to recognize duplicate content arriving from different publishers
Hint 2
Think about whether feeds should be assembled when content arrives or when readers request them
Hint 3
Plan how to insert urgent content without disrupting pagination state for active readers
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer
High-Level Architecture
The system consists of four main subsystems: ingestion, content processing, feed assembly, and delivery. Each handles a distinct concern while maintaining clear interfaces.
Ingestion pulls from publisher APIs, RSS feeds, and webhooks. A distributed queue (Kafka or Kinesis) buffers incoming items to handle traffic spikes and publisher outages gracefully.
Processing normalizes formats, extracts metadata (categories, entities, publication time), computes content fingerprints for deduplication, and writes canonical records to a content store. Use perceptual hashing or simhash to detect near-duplicates from syndication.
Feed assembly generates candidate sets using reader subscriptions and applies ranking. Delivery serves results with cursor-based pagination and manages cache invalidation.
Content Deduplication
Assign each item a content ID based on title normalization and body fingerprint. When an item arrives, check if a matching ID exists. If found, merge publisher references into the existing record rather than creating a duplicate. This canonicalization happens during ingestion before any feed considers the content.
Store mappings: content_id -> {canonical_metadata, [publisher_ids], first_seen, categories}.
Feed Assembly Strategy
Fan-out-on-write pre-builds feeds when content arrives, writing each item to relevant reader timelines. This delivers fast reads but high write amplification when many readers share interests, and makes preference changes expensive.
Fan-out-on-read queries subscriptions and assembles feeds on demand. Lower write cost and immediate preference updates, but slower reads requiring joins across category and publisher indexes.
Hybrid approach (recommended): Pre-aggregate content by category and publisher into intermediate pools during ingestion. When a reader requests their feed, merge their subscribed pools with ranking applied. This limits write amplification while keeping reads fast through pool-level caching.
Example pools: category:technology -> [item_ids with scores], publisher:techcrunch -> [item_ids with timestamps].
For a request, fetch pools for subscribed categories and publishers, merge item IDs, remove duplicates, rank by recency and engagement signals, then return top N.
Ranking and Personalization
Apply a scoring function combining:
- Recency: exponential decay from publication time
- Engagement: clicks, shares, read time from historical data
- Affinity: reader's past interactions with similar categories and publishers
- Diversity: penalize consecutive items from the same publisher
Cold-start users get a default pool built from trending content across popular categories, weighted toward general interest.
Store reader profiles: {subscribed_categories, subscribed_publishers, engagement_history}. Update asynchronously as preferences change; tolerate slight staleness for cache efficiency.
Pagination Stability
Use cursor-based pagination with a snapshot timestamp. When a reader starts scrolling, their cursor captures {last_seen_item_id, query_time}. Subsequent pages fetch only items published before query_time to prevent insertion of new content mid-scroll causing duplicates or skips.
Store cursors client-side or in a short-lived cache (15-60 minutes TTL). After expiry, a fresh query uses current time, picking up newly arrived content.
Urgent Content Distribution
Maintain a separate urgent content queue. When an item receives urgent designation (via editorial dashboard with authorization controls), inject it into a global urgent pool with expiry (e.g., 6 hours).
During feed assembly, insert urgent items at fixed positions (top 3 slots) regardless of reader preferences, then continue with personalized ranking below. After expiry, urgent items remain eligible but compete normally with personalized content.
Abuse prevention: rate-limit urgent designations per publisher, require manual editorial approval, and log all assignments for audit.
Scaling and Caching
Cache intermediate pools (category/publisher aggregations) with 5-minute TTL. Cache fully ranked feeds per reader with 10-minute TTL, invalidated when preferences change.
Partition the content store by publication date to age out old content efficiently. Partition reader profiles by user ID hash for horizontal scaling.
Use CDN for static assets and read replicas for the content store to distribute read load geographically.
Observability
Track:
- Ingestion lag per publisher source
- Deduplication hit rate
- Feed assembly latency (p50, p95, p99)
- Cache hit rates for pools and assembled feeds
- Urgent content injection rate and expiry accuracy
Alert on ingestion failures, ranking latency spikes above 200ms, or urgent content rate anomalies.
Common Mistakes
- Ignoring deduplication: Readers see duplicate content from syndication, degrading experience
- Pure fan-out-on-write: Write amplification becomes prohibitive at scale; preference changes require expensive feed rebuilds
- No pagination stability: Inserting new content mid-scroll causes duplicates or missing items
- Urgent content without expiry: Time-sensitive items remain prominent indefinitely, breaking personalization
- Synchronous preference updates: Changing subscriptions becomes slow if feeds rebuild synchronously
Trade-offs Summary
The hybrid assembly approach balances write cost (pre-aggregate by category/publisher) against read speed (merge and rank on demand). This trades moderate read latency for flexibility in preference updates and manageable write amplification. Pagination cursors trade slight staleness for stability. Urgent content injection trades perfect personalization for timely distribution of critical updates.