Design a Video Recommendation System Like YouTube: ML System Design

ML system design for YouTube-style video recommendations: framing watch time, two-tower retrieval, a multi-task ranker, serving at scale and A/B tests.

Advanced 4 min read · Updated

The question: design the recommendation system for a video platform's home page, like YouTube. Users should see videos they'll enjoy watching, new uploads should get a fair chance, and the page must load quickly for hundreds of millions of users. This walkthrough follows the ML system design framework from clarifying questions to monitoring.

1. Clarify requirements

QuestionAnswer (agreed with the interviewer)
Business goal?Increase long-term engagement: daily active users and satisfied watch time, not raw clicks
Scale?500M daily active users, a catalogue of 5B videos, about 500K new uploads per hour
Surface?Home feed; each load shows about 20 videos, users scroll for more
Latency?Recommendations returned in under 200 ms at p99
Signals available?Impressions, clicks, watch time, likes, shares, "not interested", subscriptions, searches
Constraints?Policy-violating and borderline content must not be recommended; respect age settings

2. Frame it as an ML problem

Clicks alone reward clickbait, so the ML objective is to rank videos by expected satisfied watch time. Concretely: for each (user, video) pair, predict several outcomes and combine them:

score(user, video) =   w1 · p(click)
                     + w2 · E[watch time | click]   (or p(watch > 50%))
                     + w3 · p(like) + w4 · p(share)
                     − w5 · p(not interested)
weights w are tuned by online experiments against long-term engagement

That's a multi-stage ranking problem: retrieval (candidate generation) then ranking, both learned from interaction logs. See ML problem framing.

3. Data

  • Rows: one per impression (user saw video at position p, at time t, on device d), joined with outcomes within a window: click, watch seconds, like, share, dismiss.
  • Labels: natural labels from behaviour; "not interested" and fast skips are explicit and implicit negatives.
  • Volume: 500M users × ~40 impressions/day ≈ 20B impressions/day. Downsample unclicked impressions heavily for training.
  • Splits: time-based (train on the last 30 days, evaluate on the next day). See training data.
  • Biases: position bias and exposure bias; log position and the serving model version for correction. See feedback loops.

4. High-level architecture

offlinemodelsHome requestTwo-tower ANN~1,000Subscriptionsnew uploadsTrending + freshexplore slotsLight ranker2,000 → 500Multi-task ranker500 → 100Re-rankpolicy · diversityImpression + watch logsTraining pipelinesFeature store
The serving path: several candidate sources produce about 2,000 videos, a light ranker trims to 500, a multi-task heavy ranker scores them, and re-ranking applies policy and diversity before 20 are returned. Logs feed training offline.

5. Candidate generation

Retrieval must have high recall and be cheap. Combine several sources and merge them:

  • Two-tower retrieval: a user tower over watch history, searches and demographics; a video tower over id, title, thumbnail and channel embeddings. Video vectors are precomputed and indexed in an ANN index; per request we embed the user and fetch the top 1,000 by dot product. See embeddings.
  • Subscriptions: recent uploads from subscribed channels.
  • Item-to-item: videos co-watched with the user's last few watches.
  • Trending and fresh: popular in the user's region and an exploration source for new uploads (cold start).

6. Ranking

A light ranker (a small model on cheap features) cuts 2,000 candidates to 500. The heavy ranker is a multi-task deep network with heads for click, watch time, like, share and dismiss, sharing lower layers. See choosing a model and learning to rank.

Feature groupExamples
UserLong-term topic interests, language, country, account age, user embedding
VideoDuration, age, channel, topic, global CTR and average watch percentage, video embedding
User-videoHas watched this channel, time since last watch from channel, embedding similarity
ContextTime of day, device, network speed, position on page
SessionVideos watched in the last 30 minutes, topics of the current session

Position is a training feature set to a constant at serving time, to separate relevance from placement bias.

7. Re-ranking

  • Remove policy-violating, borderline and age-restricted videos, and anything already watched or dismissed.
  • Diversity: limit videos per channel and per topic in the first screen.
  • Freshness: a small boost for recent uploads, and reserved slots for exploration.

8. Serving and scale

Requests     : 500M DAU × ~10 home loads/day = 5B/day ≈ 58K RPS avg, ~150K peak
Retrieval    : ANN over 5B videos is too big; index only the ~500M eligible
               (recent or popular) videos: 500M × 128 dims × 1 B (int8) ≈ 64 GB per replica
Ranking      : 500 candidates × 150K RPS = 75M scores/s → GPU batching, ~2-5K GPU inference
               servers at a few thousand candidate-scores per ms each (illustrative)
Latency plan : features 20 ms | retrieval 30 ms | light 20 ms | heavy 60 ms | re-rank 10 ms
               → ~140 ms, leaving headroom under 200 ms p99
Fallback     : if the heavy ranker times out, serve the light ranker's order
  • User embeddings are recomputed in near real time from recent watches, so the feed reacts within a session.
  • Precompute recommendations for inactive users in batch and refresh on login, cutting peak load.
  • Cache video features aggressively; they change slowly. See model serving.

9. Evaluation

StageOfflineOnline
RetrievalRecall@1000 of the next watched videoShare of watch time from each source
RankingNDCG@20, per-head AUC, calibration of watch-time predictionsWatch time per user, daily active users
GuardrailsSlice metrics (new users, small languages)Dismiss rate, survey satisfaction, creator diversity, policy-violating impressions

Ship only after an A/B test shows gains in long-term metrics; keep a long-running holdout to measure cumulative effects. See ML evaluation.

10. Monitoring and iteration

  • Retrain the ranker daily (incrementally) and the retrieval towers weekly, then rebuild the index; see continual learning.
  • Monitor feature null rates, score distributions, catalogue coverage and impression concentration.
  • Watch for feedback loops: falling new-video reach or rising concentration of impressions trigger review.

Follow-up questions to expect

  • *How do you stop clickbait?* Multi-objective scoring with satisfaction signals and dismiss predictions, plus survey-based labels.
  • *How does a brand-new video get its first views?* Content embeddings in the video tower, channel priors and exploration slots.
  • *How do you recommend to a logged-out user?* Context and popularity in the region, then session-based signals.
  • *How do you know watch time didn't rise only because videos got longer?* Track watch percentage and satisfaction, and compare by duration bucket.

Where it’s used

Long-form video

Home feed and watch-next recommendations with multi-objective ranking.

Short-form video

The same funnel with faster session-level feedback and heavier exploration for new uploads.

Streaming services

Smaller catalogues, so ranking leans on rows and artwork personalisation more than retrieval.

In an interview

  • Frame the objective as satisfied watch time, not clicks, with a multi-task scoring formula.
  • Draw the funnel with candidate counts and per-stage latency.
  • Use multiple candidate sources, including exploration for new uploads.
  • Evaluate retrieval and ranking separately, and launch on long-term online metrics.

Frequently asked questions

How does YouTube's recommendation system work at a high level?

It is a multi-stage funnel: candidate generation from a two-tower model and other sources narrows billions of videos to a few thousand, a ranking model predicts several engagement and satisfaction outcomes for each, and re-ranking applies policy, diversity and freshness rules.

What should a video recommender optimise?

Satisfied watch time and long-term engagement rather than clicks alone, combining predicted clicks, watch time, likes, shares and dismissals with weights tuned by online experiments.

Further reading