Design a Recommendation System
Understanding the Problem
🎯 What is a recommendation system? A recommendation system picks, out of a catalog far too large to browse, the handful of items each user is most likely to want right now. It's the rows on the Netflix or Prime Video home screen, the "customers who bought this also bought" strip on a product page, and the grid of posts on Instagram Explore. Behind each one is the same pipeline: collect what users do, turn it into signals, and at request time narrow millions of items down to a ranked few dozen in a fraction of a second.
You'll hear three versions of this question, and they're the same system with different emphasis:
- Movies and shows (Netflix, Prime Video): a catalog of tens of thousands of titles, personalized rows, and taste that changes slowly. Lots can be precomputed.
- "Also bought" (Amazon): item-to-item recommendations on a product page. Barely personalized, huge catalog, perfect for offline computation and caching.
- Explore (Instagram): billions of posts, most of them new in the last few days. Freshness matters, so it leans on online retrieval and ranking.
This is the system design version: we'll treat the models as components with clear inputs and outputs, and focus on data flow, serving, latency and freshness. The modeling itself is an ML system design question.
Functional Requirements
Core Requirements
- Users should see a personalized home page of recommendation rows ("Because you watched X," "Top picks for you").
- Users viewing an item should see related items ("customers also bought," "more like this").
- Users should be able to browse an endless, personalized Explore feed of fresh content they haven't seen.
- The system should record user interactions (views, clicks, plays, purchases, likes) and use them to improve recommendations.
Below the line (out of scope)
- Model architecture and training details.
- Ads (a separate auction), search ranking and content moderation.
Non-Functional Requirements
Some numbers to agree on with your interviewer:
Core Requirements
- The system should serve 200 million daily users with peaks of about 50,000 recommendation requests per second.
- A recommendation request should return in under 200 ms at p99, since it's on the critical path of the home page.
- Recommendations should reflect new behavior quickly: within minutes for Explore (you liked three cooking videos, now show more), within a day for movie rows.
- The system must always return something. A failing model or data store should degrade to less personal results, never to an empty page.
- The system should support running many experiments at once (different models, different row orders).
Below the line (out of scope)
- Multi-region consistency of user state. Each region can serve from slightly stale replicas.
Do the math on ranking first, because it decides the architecture. Say a good ranking model costs about 10 microseconds of compute per item on CPU (realistic for a gradient-boosted tree or a small neural network with batching). Scoring a catalog of 500 million products for one request would take 5,000 seconds. Even a 50,000-title video catalog is half a second per request, times 50,000 requests per second.
So we can't score the whole catalog. We need a funnel: a cheap step that narrows millions of items to around 1,000 candidates, then an expensive model that scores just those. Even then, 50,000 requests per second × 1,000 candidates = 50 million model evaluations per second, which is a serious inference fleet. That's why anything that can be precomputed should be.
On the event side: 200M users generating around 100 events each per day is 20 billion events a day, about 230,000 per second on average. Those feed both training data and real-time features.
The funnel is the single idea interviewers most want to hear: retrieval narrows millions to about a thousand cheaply, ranking orders those carefully, and re-ranking applies business rules. Everything else in the design hangs off it.