Skip to main content
← PROBLEMS / SYSTEM-DESIGN
An end-to-end domain learning journey

Design a Personalized News
& Content Recommendation Engine.

Design a personalized news and content recommendation engine serving 50M daily active users at 80K QPS under a 50ms p99 latency SLA, with <60-second cold-start indexing for breaking news.
Start the journey7 stages· Last modified Nov 24, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

When inference latency or GPU memory limits bind throughput, use parallel multi-source retrieval, batched GPU ranking, and an async Kafka feedback loop that updates user embeddings and trending buckets in real time.

TL;DR30-second simplified summary
▾

To hit 80K QPS under 50ms, run parallel HNSW + Trending + CF retrieval, strip seen items via 2 KB Redis Bloom filters, score 1,000 items in one FP16 TensorRT batch, and apply MMR diversity.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
Two-Tower Retrieval & Multi-Stage Ranking Funnel
Two-Tower Retrieval & Multi-Stage Ranking scales personalized recommendations from 10M+ items down to 10 final results under 50ms by decoupling fast embedding similarity search from heavy cross-feature scoring.
Full walkthrough · 7 stages
01
foundation

Traffic, Latency & Freshness SLAs.

Why this matters: Establish QPS, corpus churn, and latency budgets across each serving hop.

Think of Traffic, Latency & Freshness SLAs as the intuition layer for Design a Personalized News & Content Recommendation Engine: Establish QPS, corpus churn, and latency budgets across each serving hop.

50M DAU generating ~10 feed loads/day averages ~6K QPS, peaking at 80K QPS. With a 50ms p99 end-to-end budget, we allocate 5ms to Gateway + User Profile, 10ms to parallel Retrieval, 10ms to Feature Hydration, 18ms to GPU Ranking, and 7ms to MMR Re-Ranking + network.

SLA Budget

80K QPS Peak & 50ms Latency Allocation

API Gateway (5ms)Edge entryRetrieval Fan-Out(10ms)Candidate recallHydrator (10ms)Feature fetchGPU Ranker + MMR(25ms)Final scoring15ms elapsed

1.60s Freshness: Breaking articles must be embedded and indexed within 60 seconds.

2.Strict Timeouts: Each stage enforces hedged requests and partial-result fallbacks.

Allocating explicit millisecond budgets per stage keeps end-to-end p99 under 50ms.

02
foundation

End-to-End Serving & Feedback Topology.

Why this matters: Connect synchronous feed serving with asynchronous Kafka interaction loops.

Think of End-to-End Serving & Feedback Topology as the intuition layer for Design a Personalized News & Content Recommendation Engine: Connect synchronous feed serving with asynchronous Kafka interaction loops.

On the read path, the API Gateway fetches user embeddings from Redis, queries multiple candidate generators, hydrates features, and runs GPU scoring + MMR re-ranking. On the write path, impressions, clicks, and dwell times flow into Kafka to update Redis user profiles and HNSW.

System Topology

Synchronous Feed Path & Async Kafka Loop

Feed API GatewayOrchestratorMulti-SourceRetrieval1000 candidatesGPU Scorer & MMRTop 10 feedKafka Feedback BusOnline updaterPasses hydrated candidates

1.Graceful Fallback: If personalized retrieval times out, serve regional trending news.

2.Impression Logging: Log exact ranker scores to enable unbiased offline replay.

Separating the synchronous serving path from async Kafka updates keeps feed latency predictable.

Engineering Decision Framework
Problem
How to implement Design a Personalized News & Content Recommendation Engine without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
When inference latency or GPU memory limits bind throughput, use parallel multi-source retrieval, batched GPU ranking, and an async Kafka feedback loop that updates user embeddings and trending buckets in real time.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Design a Personalized News & Content Recommendation Engine experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
intermediate

60-Second News Ingestion & HNSW Hot-Indexing.

Why this matters: Embed and index breaking news articles into live HNSW shards without lock stalls.

Think of 60-Second News Ingestion & HNSW Hot-Indexing as the intuition layer for Design a Personalized News & Content Recommendation Engine: Embed and index breaking news articles into live HNSW shards without lock stalls.

When a CMS publishes an article, a Kafka consumer runs the Item Tower encoder + NER tagger on GPU (<200ms) and streams the 128-d vector to HNSW shards. Shards use double-buffered delta segments (mutable HNSW delta + immutable base) so writes never block concurrent reads.

Freshness Pipeline

CMS Publish -> Item Tower -> HNSW Delta Index

CMS Publish WebhookContent triggerItem Tower EncoderFeature extractorHNSW Delta SegmentLive vector indexBreaking News ZSETCold-start poolAppends to delta HNSW

1.Delta + Base Segments: Hourly background merges compact delta segments into the main HNSW graph.

2.Dual Insertion: Inserting into both HNSW and Trending ZSET guarantees immediate discoverability.

Delta HNSW segments and regional trending ZSETs make breaking news searchable in seconds.

04
intermediate

Seen-Article Filtering at 80K QPS.

Why this matters: Never recommend an article the user already read or scrolled past.

Think of Seen-Article Filtering at 80K QPS as the intuition layer for Design a Personalized News & Content Recommendation Engine: Never recommend an article the user already read or scrolled past.

Storing full 30-day read histories per user in SQL is too slow. Instead, each user has a compact 2 KB Counting Bloom Filter or Roaring Bitmap in Redis storing the last 2,000 seen article IDs, checked in O(1) right after retrieval.

Deduplication

Redis Per-User Bloom Filter Seen-History

Viewport ImpressionSeen triggerRedis 2KB BloomFilterO(1) membershipPost-RetrievalFilterFeed hygieneSafety ValveEmpty-feed guardFilters 1000 -> ~800

1.1% False Positive: A 2 KB Bloom filter with 1% FP rate is imperceptible to users and saves 80% RAM.

2.Empty-Feed Guard: Always fall back to unseen trending items if filtering leaves too few candidates.

Compact 2 KB per-user Bloom filters eliminate repeat articles at negligible memory cost.

05
intermediate

Batched TensorRT GPU Ranking.

Why this matters: Maximize GPU throughput for 1,000-candidate DeepFM scoring.

Think of Batched TensorRT GPU Ranking as the intuition layer for Design a Personalized News & Content Recommendation Engine: Maximize GPU throughput for 1,000-candidate DeepFM scoring.

Sending 1,000 single-item requests wastes GPU PCIe bandwidth. The Ranker packages all 1,000 candidates for one user into a single contiguous FP16 tensor, using TensorRT dynamic batching and shared user-feature broadcasting to score all 1,000 items in ~14ms.

GPU Inference

User-Broadcast TensorRT FP16 Scoring

1x User VectorZero-copy context1000x Item MatrixCandidate batchTensorRT DeepFM14ms scoringLightGBM FallbackGPU overload guardStreams item matrix

1.10x Less PCIe Traffic: Broadcasting the user vector on-device cuts host-to-GPU copy size by 90%.

2.CPU Fallback: A lightweight LightGBM model on CPU guarantees availability during GPU spikes.

Broadcasting user features on-device and fusing FP16 kernels hits 14ms ranking latency.

06
advanced

Exploration vs Exploitation (Bandits).

Why this matters: Bootstrap new articles and prevent echo chambers with contextual bandits.

Think of Exploration vs Exploitation (Bandits) as the intuition layer for Design a Personalized News & Content Recommendation Engine: Bootstrap new articles and prevent echo chambers with contextual bandits.

Pure exploitation starves new articles of clicks. We reserve 1–2 slots in the top-10 feed for a LinUCB / Thompson Sampling bandit over fresh (<2h) articles, using their early CTR confidence intervals to promote winners into the main HNSW index.

Explore/Exploit

Thompson Sampling Slot Injection

Fresh Articles(<2h)Exploration poolThompson SamplerUncertainty scorerFeed Slot #4 & #8Controlled trafficPromotion GateMain corpusInjects top explorer

1.Informative Prior: Beta(1, 20) reflects a 5% baseline CTR prior to avoid noisy 1/1 spikes.

2.Bounded Regret: Capping exploration to 1-2 lower slots protects overall feed engagement.

Thompson Sampling gives breaking articles fair exposure without risking top-slot relevance.

07
advanced

Continuous Online Training & Canary Rollouts.

Why this matters: Ship updated DeepFM weights hourly with zero-downtime shadow validation.

User preferences shift hourly during major news events.

Flink joins impressions with 15-minute delayed clicks/dwell labels to emit training examples.

Continuous ML

15-Min Label Joiner & Hourly Canary Deployment

Impression StreamTraining baseFlink 15m LabelJoinerPositive/negativeHourly IncrementalTrainerWeight updater5% Canary A/B GateSafe rolloutStreams labeled examples

1.Attribution Window: A 15-minute Flink join captures 95% of news clicks before emitting training rows.

2.Calibration Gate: Never promote weights whose predicted CTR drifts >3% from empirical CTR.

Hourly incremental training paired with calibration gates keeps rankings fresh and safe.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

How do you ensure a breaking news article published 30 seconds ago appears in personalized feeds if the Two-Tower item index normally updates hourly?

Recommended Learning Flow