How would you design a movie recommendation system for a small app with users and movies? Using a rating table where Movie A has ratings , Movie B has and Movie C has from three users, what is the cosine similarity between Movie A and Movie B, and how much storage is needed to precompute recommendations per user nightly?
ML system design, Case studies
Level L2 Elementary. Length Medium. Nature Th+Mat Both.
What's being asked
Whether you can design a small-scale recommender end to end, compute an item–item cosine similarity by hand, and size a simple batch storage table.
Key idea
At users and movies, you do not need a complex real-time neural pipeline. Start with a popularity baseline, upgrade to item–item collaborative filtering using cosine similarity, precompute the top picks per user each night in a tiny table, and test changes with an A/B experiment.
Steps
- Clarify scale, objective and metrics: with users and movies ( mostly empty cells), nightly batch updates on one machine are plenty. Help users discover and finish movies by tracking recall@20 or NDCG@20 (normalised discounted cumulative gain at 20) offline on held-out watches, and recommendation CTR (click-through rate) plus watch-completion rate online.
- Specify data, labels and item–item cosine similarity: combine sparse explicit 1–5 ratings with dense implicit clicks and watch duration. Compare movies via cosine similarity . For Movie A and Movie B : (By contrast, Movie C has , so a user who liked A gets B ranked above C.)
- Build the model (start simple, then improve): start with a popularity baseline (most-watched movies this week, or top by genre). Next, compute the item–item similarity matrix and score unrated movies for each user by weighted similarity to movies they liked; later, add matrix factorisation or genre/metadata features.
- Serving architecture and storage calculation: run a nightly batch job that computes the top recommendations per user and writes them to a fast lookup table (such as Redis or Postgres). Storing per entry ( movie ID plus score) requires: so the entire table fits effortlessly in memory with sub-millisecond reads.
- Evaluation, cold start and interviewer trade-offs: handle cold-start users (new users with no history) with the popularity or onboarding-genre baseline, and validate the new recommender against popularity in an online A/B test. An interviewer will probe cold-start movies (solved by genre/cast metadata), filter bubbles (solved by mixing in some popular or diverse picks) and batch staleness versus live updates.
- Monitor and iterate: track daily batch job success, cache coverage, click-through rate and diversity of shown movies, and refresh similarities nightly as new watches arrive. The large-scale video recommendation case study builds on this by adding two-stage retrieval and ranking for millions of items and real-time session features.
Common mistakes
- Trying to run real-time deep-learning inference over all movies for users when a nightly batch table solves the problem simply.
- Having no fallback for brand-new users or newly added movies (the cold-start problem).
- Recommending only near-identical sequels so the feed feels repetitive, instead of enforcing basic diversity.
How long your answer should be
About 4–5 minutes; walk through the design stages, cosine calculation and storage estimate.
Read this
Previous in ML system design: How would you design a spam filter for a small college email server that receives emails a day, of which about are spam? If your model achieves recall and a false-positive rate, how many spam emails are missed and how many legitimate emails are wrongly flagged per day?
Next in ML system design: What are data, tensor and pipeline parallelism in distributed training, and when should you use each?