How would you design a video recommendation system for a large video platform?
ML system design, Case studies
Level L4 Advanced. Length Long. Nature Th+Mat Both.
What's being asked
Whether you can structure a large-scale multi-stage retrieval and ranking architecture, align the training objective with long-term satisfaction rather than clickbait, and handle scale, diversity and feedback loops.
Key idea
Scoring millions of videos per request is impossible with a heavy ranker, so the system splits into fast multi-source candidate generation (narrowing millions to hundreds) and feature-rich deep ranking. Following Covington et al. (2016), weighting positive impressions by watch time in logistic regression makes the predicted odds approximate expected watch time, curbing clickbait while multi-task heads and re-ranking balance engagement, satisfaction and diversity.
Steps
- Clarify requirements and scale: confirm the surface (home feed vs up-next), latency SLA (service-level agreement, roughly 100–150 ms end-to-end) and corpus churn (millions of daily uploads). Back-of-envelope estimate: with active videos and -dimensional embeddings stored in fp32 (32-bit floating point, 4 bytes), the item embedding table uses (), or in int8 (8-bit integer), fitting in RAM (random-access memory) for ANN (approximate nearest neighbours) search. At QPS (queries per second), narrowing to 500 candidates requires the ranking network to score user–video pairs per second.
- Define the ML objective and metrics: do not optimise raw CTR (click-through rate) alone, as it rewards clickbait thumbnails that users abandon immediately. Instead, optimise expected watch time and satisfaction. In weighted logistic regression (Covington et al., 2016), clicked impressions get positive weight (observed watch time) and unclicked impressions get weight ; when the click probability is small, the learned odds approximate expected watch time, e.g. for and , (close to ). Offline, measure weighted log loss, calibration, AUC (area under the ROC curve) and NDCG@k (normalised discounted cumulative gain at rank k); online, track total watch time per user, session length, survey-based satisfaction, and guardrail metrics such as hide/dislike rates and latency.
- Prepare data and labels: use abundant implicit feedback (impressions, clicks, watch duration, completion ratio) alongside sparser explicit signals (likes, dislikes, shares, 'not interested' and user satisfaction surveys). Remove accidental rapid bounces (e.g. watches under a few seconds), handle cold-start and fresh uploads explicitly, and account for selection and position bias—because users only interact with videos the old model showed at top positions, naive training reinforces popularity bias.
- Engineer features for both stages: candidate generation uses user watch-history and search-token embedding averages, language, country, device and an 'example age' feature (days since upload, set to zero at serving so the model stops favouring stale hits). The ranking stage adds rich cross-features: video duration, channel affinity (past watches and time since last watch from that channel), candidate-source provenance, impression count (to penalise repeatedly ignored videos) and normalised continuous transformations such as , and . An interviewer will probe how you prevent leakage from future video popularity or watch counts.
- Design the multi-stage model stack: start with popularity/collaborative-filtering baselines, then move to a two-stage neural architecture. (1) Candidate generation combines multiple sources: a two-tower or softmax DNN (deep neural network) with ReLU (rectified linear unit) layers trained via sampled softmax for personalised retrieval, plus co-watch graphs, trending/freshness pools and subscribed channels, retrieving roughly 500 candidates. (2) A multi-task deep ranking network shares lower layers and outputs separate heads for predicted click, expected watch time, like/share and dislike/dismiss, combined into a tunable final utility score. (3) A lightweight re-ranker enforces diversity across creators/topics, freshness and creator fairness (e.g. via greedy maximal marginal relevance or business constraints).
- Plan serving architecture and latency: split a budget roughly as for user-feature lookup and parallel candidate generators (ANN vector search + graph/trending caches), for batched GPU/accelerator inference of the multi-task ranker (computing user-side tower features once per request rather than 500 times), for re-ranking and filtering already-watched or policy-violating videos, and network overhead. Interviewers will probe the trade-off between candidate pool size ( vs ) and ranking latency.
- Validate, explore and launch carefully: evaluate offline on time-split logs and counterfactual IPS (inverse propensity scoring) on a small randomised-exploration traffic slice. Inject controlled exploration (such as epsilon-greedy or Thompson-style uncertainty bonuses on fresh videos) so new creators and unseen genres gather feedback and break filter bubbles. Roll out via shadow logging for latency/skew checks, then canary, then a user-level A/B test (cluster-randomised if creator-side feedback loops matter) monitoring watch time, diversity and negative feedback.
- Monitor and iterate continuously: retrain candidate and ranking models continuously or hourly to absorb new uploads and trending topics, monitor embedding staleness and ANN index rebuild lag, and alert on CTR-vs-watch-time divergence (a sign of clickbait drift) or creator-concentration spikes. Key trade-offs an interviewer will probe include short-term watch time vs long-term retention, exploration cost vs relevance, and tuning multi-task head weights.
Common mistakes
- Optimising click-through rate alone, which systematically amplifies misleading clickbait thumbnails and hurts long-term user retention.
- Omitting the 'example age' feature (or freshness signal) during candidate training, causing the model to over-recommend old popular videos and starve newly uploaded content.
- Using the same heavy cross-feature ranker on the entire corpus, or skipping a diversity re-ranker and showing ten nearly identical videos from one channel.
How long your answer should be
8–10 minutes; emphasise the two-stage funnel, watch-time weighting and multi-task/re-ranking trade-offs.
Read this
Previous in ML system design: How would you design a spam detection system for a large messaging or email platform?
Next in ML system design: How would you design an ad click-through rate (CTR) prediction system?