Design a recommendation system

Recommend items (videos, products, posts) that each user is likely to engage with.

Why interviewers ask it

It tests the two-stage pattern (retrieve, then rank), feature consistency, feedback loops, and how to measure success.

Functional requirements

Non-functional requirements

From version 1 to the final design

  1. Version 1: show everyone the most popular items.
  2. Version 2: item-to-item similarity ('people who watched X also watched Y').
  3. Version 3: embeddings to gather candidates, plus a ranking model.
  4. Version 4: a feature store, re-ranking rules, exploration and A/B testing.

The design, step by step

  1. Two stages. Candidate generation retrieves about 500–1,000 items quickly (embedding similarity with approximate nearest-neighbour search, items often bought together, popular items). Ranking then scores those candidates with a richer model using user, item and context features.
  2. Re-ranking applies business rules: variety, freshness, removing items already seen.
  3. Models train offline on logged interactions; features come from a feature store, defined the same way for training and serving.
  4. Online A/B tests measure the real impact of every change.

Deep dives

Common mistakes

Not true: Offline metrics: a better score means users will like the recommendations more.
In fact: Offline scores are measured on past behaviour, which the old system shaped. Only an online A/B test shows what real users do.

In the interview

It is a two-stage system. Candidate generation pulls about a thousand items cheaply, using embedding similarity and simple sources. Then a ranking model scores them with user, item and context features from a feature store. A final re-ranking step applies variety and business rules. Models train offline on interaction logs, and every change is checked with an online A/B test.

Part of Unit 9: AI and ML system design in the free System Design course.