Classic design · Senior
Video recommendation
Classic interview design. Key points: candidate generation + ranking, two-tower, implicit feedback, cold start, and A/B.
Short answer
Classic interview design. Key points: candidate generation + ranking, two-tower, implicit feedback, cold start, and A/B. The case is recommending the next video ("up next") while the user watches another. For the design, scale assumptions are adopted: about 1B videos, 1B daily active users, 5 videos on screen at once, and a response in a 250ms window.
01 · CONTEXT AND REQUIREMENTS
What recommending the next video means
The case is recommending the next video ("up next") while the user watches another. For the design, scale assumptions are adopted: about 1B videos, 1B daily active users, 5 videos on screen at once, and a response in a 250ms window. This agreement is the starting point of the requirements gathering.
Before the model comes the business goal. Optimizing click-through rate is easy to measure but can lead to greedy behaviors; maximizing watch time aligns better with an ad-supported platform; and the option adopted in the case is quality-adjusted watch time.
| Criterion | Click-through rate | Watch time | Quality-adjusted time |
|---|---|---|---|
| Vantagem | Easy to measure and optimize | Aligns with an ad-supported platform and controls the retention problem | Combines time with signals such as ratings, completion rate, and sharing |
| Risco | Sensationalist thumbnails generate clicks, but without retention the user leaves | May promote addictive, low-quality content | May still miss factors such as creator sustainability and diversity |
02 · STAGED ARCHITECTURE
From the entire catalog to a few videos
Systems for recommendation at scale almost always use a multi-stage architecture, relatively standard in the industry. The YouTube neural network paper describes two networks, one for candidate generation and another for ranking; the design below extends this funnel with a light ranker and a final re-ranking, as in the case.
The app requests next-video recommendations from the recommendation service, which coordinates the following stages.
Several candidate generators run in parallel, with universal or personalized context, and many of them are thin interfaces over the vector database.
Limited-context generators can be precomputed and cached.
The light ranker shrinks the candidate set with features that are fast to compute, and what matters in it is recall.
The heavy ranker uses the full feature set to score the remaining videos.
Re-ranking adjusts the list as a whole, balancing engagement, creators, and platform health.
| Criterion | Light ranker | Heavy ranker |
|---|---|---|
| Prioridade | High recall, low latency, and high throughput | High precision, high quality, and lower throughput |
| Typical model | Tree-based model, such as GBDT | Transformer-based architecture, which has become the preferred one in recommendation |
| Custo | Runs on CPU with latency under a millisecond | Computationally more expensive than DLRM |
In the YouTube paper, scoring the entire catalog within tens of milliseconds requires approximate scoring, and the service generates hundreds of candidate videos through an approximate nearest neighbor search.
03 · DATA AND MODELS
What the model learns and from what
Most training data comes from implicit feedback. Explicit signals have high quality but are relatively rare. Videos that make the user leave the platform are among the strongest implicit negative signals.
Video content features can be computed once, at upload or edit time, and cached for a long time. Engagement features are more dynamic and need more frequent updating, with careful normalization.
Computing and updating these features is typical work for a data pipeline.
In the design, each user interaction becomes an event in a queue, and a pipeline turns those events into training examples.
Most examples come from implicit feedback, and videos that make the user leave the platform are strong negative signals.
Two parallel towers learn embeddings of the user and the candidate videos, from triplets of user, positive video, and negative video.
In negative sampling, hard negatives are favored.
The user and candidate video embeddings go to the vector database, from where they are retrieved.
The generator queries the database with an embedding and retrieves the K nearest vectors; embeddings and candidate results can be cached.
The case's final ranker uses a transformer-based architecture, optimized for several prediction tasks. Watch time is a regression head and click probability is a binary classification head. Predicting several outcomes at once lets it learn richer representations of different aspects of behavior.
The training examples are generated by users, but also by the current system. The case's loss includes a correction for position bias in historical data.
04 · INFERENCE AND EVALUATION
Serve fast and measure carefully
You can precompute and store in cache the embeddings of all videos. User embeddings and candidate generation results are also cached.
The final outputs can be evaluated with ranking metrics such as NDCG, MAP, and precision and recall. Since each stage is a new source of error for the following ones, the recall of the candidate generators should also be evaluated.
The gold standard of online evaluation is the A/B test. In the YouTube paper, the authors determine final effectiveness through live experiments, because live A/B results do not always correlate with offline experiments. Experiments also suffer from novelty effect: the new system may yield better results than it otherwise would.
05 · DEEP DIVES
Cold start, feedback loops, and exploration
New users and videos lack the behavioral data that feeds the heavy ranker. For new users, demographic information and onboarding preferences are used to group them with similar users. For new videos, features are extracted from the content itself and controlled exploration is used.
A new video does not yet have user behavior; features are extracted from the content itself, with multimodal models that analyze thumbnails, titles, descriptions, transcripts, and the video.
The exploration service exposes the new video to a diverse but limited audience, to obtain initial signals without risking the broad base.
What was shown and how viewers reacted is logged, and techniques such as counterfactual logging help reduce bias in the training data.
Once there is some behavioral signal, the video moves to a more personalized approach.
Recommenders create feedback loops that affect the user experience. As mitigation, the case proposes counterfactual logging, inverse propensity reweighting, losses that penalize overexposure, and diversity constraints on the list.
There is also the balance between showing what the user already likes (exploitation) and including wildcards that may reveal new interests (exploration). This problem is handled with techniques such as Thompson sampling or contextual bandits.
Frequently asked questions
What is Video recommendation?
Classic interview design. Key points: candidate generation + ranking, two-tower, implicit feedback, cold start, and A/B.
What does the Video recommendation design cover?
It is organized in these sections: What recommending the next video means, From the entire catalog to a few videos, What the model learns and from what, Serve fast and measure carefully, and Cold start, feedback loops, and exploration.
How long is Video recommendation and what level is it?
It takes about 16 minutes to read and is rated Senior level.
Now design it yourself
Run this case as an interview in the System Design school: you make the decisions, the tutor challenges them and you see how your design scores.