Skip to content

How to design a recommendation system

The first sections are free. The deep dives, level expectations and quiz are part of Pro.

On this page
Asked at
Practice this question

The problem

A recommendation system picks rows of titles for each profile's home page and moves those picks as the viewer watches. Two decisions carry the answer. First, a funnel: the catalog of over 10,000 titles is cut in stages to about 50, so the expensive model scores a few hundred titles rather than the whole catalog on each of millions of page loads a second. Second, timing: most pages are prepared ahead and cached, then adjusted with a light pass on what the viewer just did, because preparing 300 million pages a day is a small fraction of the work of ranking live for each request. Everything else, the event stream, the feature store with its offline and online halves, the popular-titles fallback, exists to make those two decisions hold up.

Clarifying questions

AskWhy it mattersA typical answer

How big is the catalog, and how many people and requests are we serving?

The catalog size against the request rate decides whether one model can score the whole catalog per request or whether candidates have to be narrowed first.

Over 10,000 titles, 300 million users, and millions of home page requests a second at peak. Storage for events and features runs to petabytes.

How quickly must a play change the page: within the session, or by tomorrow?

This is the decision between preparing pages ahead and ranking live. A seconds-level answer forces fresh signals into the serving path; an hours-level answer lets a nightly job do most of the work.

The picks should move as the viewer watches. A show they finished a minute ago shouldn't be pushed again on the next load. Long-term taste can be hours old.

Which signals do we record, and are they equally trustworthy?

A hover and a completed play tell you very different things, and the event schema and feature weights depend on which signals exist.

Plays and hovers both. Treat a hover as a weak hint and a play, especially a completed one, as a strong one.

Is the model itself in scope?

The ML design round owns model choice and training. In this round you build what feeds the model and what serves its output, so you want to spend time there.

No. Assume a ranking model exists and can be retrained. Design the pipeline around it.

What should a brand-new profile see?

A profile with no history has no personal features. Whatever you show it is also a natural fallback page for everyone when ranking fails, so the two needs can share one design.

Something sensible: popular titles for their country, plus anything a sign-up taste picker gives you.

When ranking is slow or down, does the page wait, or show something generic?

It fixes the order of fallbacks and tells you that page availability ranks above personalization quality.

The page must load. Stale or generic rows beat an empty screen.

Do rows need a reason label, like 'Because you watched'?

If they do, each candidate has to carry where it came from through ranking, which changes what candidate generation returns.

Nice to have. Keep the source of each candidate so you could add it.

The requirements menu

RequirementScopeWhy

Show each profile rows of recommended titles on the home page

Core

The product. The whole serving path, from candidate sources to the row cache, exists for this call.

Update the picks as the viewer watches

Core

Separates this from a nightly batch job. It forces fresh signals into features and a light adjustment at serving time.

Record viewing signals (plays, hovers) to learn from

Core

The write path. Events feed both the fresh features and the training data, so the stream has two readers from day one.

Show something sensible to a new viewer with no history

Core

A profile without history has no personal features. The popular-by-country page you build for this is also the fallback when ranking fails.

Keep a 'Continue watching' row from playback position

Optional

Worth taking: it's a row built from the viewer's own state rather than a model, cheap to serve and directly useful. It also doubles as a candidate source.

Serve similar titles on a title's detail page

Optional

It's in the API and reuses the similar-titles table that candidate generation already needs, so it costs one lookup. Take it if time allows.

Label each row with its reason, such as 'Because you watched'

Optional

Tempting because it builds trust with viewers. It needs each candidate to keep its source through ranking, which is a small change if you plan for it and a painful one later.

Filter by country rights and the profile's maturity setting

Optional

A real constraint that belongs as a filter before ranking. Name it as a stage, don't design the rights system.

Drop titles the viewer finished or marked 'not interested'

Optional

A filter in the final pass. Cheap, and it's the clearest case of a fresh signal that has to reach the page within seconds.

Personalized artwork for each title

Out of scope

A second ranking problem layered on the first: which image to show for a title already chosen. Mention it, leave it.

Push notifications about new titles

Out of scope

A separate delivery system with its own rate limits and quiet hours. It could reuse the candidate sources, but not in this round.

Model choice and training, which belong to the ML design round

Out of scope

Say which inputs the model takes and where its output goes, then treat it as a box.

The experiment platform

Out of scope

If ranking changes are to be compared in experiments, keep a model version on each built row for later analysis, and stop there.

Video playback and the CDN

Out of scope

Once a viewer presses play, a different system takes over. Playback only matters here as the source of play events.

Non-functional requirements

RequirementWhat it forces

Meta-scale traffic: millions of requests a second

Running the full ranking funnel for each request would mean hundreds of feature lookups per request at that rate, so most pages have to come from a cache of rows built ahead, with the ranking service handling misses and refreshes. Services on the read path stay stateless so they scale by adding machines, and the online feature store is read in batches, once per request for the profile and from a local copy for titles.

Candidates narrowed in stages, from over 10,000 down to about 50

Candidate generation and ranking are separate services with different budgets: retrieval from cheap sources gets the catalog to 1,000, a light model to 500, the heavy model to about 50. Each stage has its own cutoff you can tune, and the heavy model's cost per request is fixed by its input count, not the catalog size.

5% to 10% of slots kept for exploration

The final assembly step reserves a few slots on the page for titles the model hasn't learned about yet rather than filling the page purely by score. Those impressions get flagged in the event log so training knows they were exploration, not the model's choice.

The home page still loads when a dependency fails

Each call from the home service carries a timeout, and the fallback chain runs the cached page, then the country's popular titles, with the last step depending on as little as possible: a small table and nothing on the ranking path. Personalization quality degrades; the page is meant to keep loading.

Estimates

QuantityWorkingResultWhat it sizes

Heavy-model scorings saved by the funnel

Heavy model across the entire catalog: over 10,000 scorings per request. With the funnel: the light ranker scores 1,000 and the heavy ranker 500, so 10,000 ÷ 500 = 20 times fewer heavy scorings, and 1,500 item scorings in total against 10,000, however they are batched into inference calls

About 20 times fewer heavy-model scorings per request, 500 instead of over 10,000

Why the ranking service is a funnel: the heavy model's cost per request is set by the 500 it sees, not by the catalog.

Feature lookups a second if ranking ran live

Take 1 million requests a second, the low end of millions, × 500 candidates reaching the heavy model = 500 million candidate lookups a second. Fetch the profile's features once per request and the title features from a local copy, and the online store sees about 1 million profile reads a second instead

500 million candidate lookups a second, cut to about 1 million profile reads a second by batching and local title features

The load on the online feature store, and why per-request batching and a local title-feature copy are the first fixes.

Title features held in each ranker's memory

Over 10,000 titles × an assumed 1 KB of features per title = about 10 MB; even ten times that is about 100 MB

Tens of megabytes

Why title features can be a local copy refreshed every few minutes rather than a remote read per candidate.

Row cache for all profiles

About 50 title ids × 8 bytes per 64-bit id = 400 bytes of ids per page; with row names, sources and a built-at time, assume about 1 KB per profile. Treating 300 million users as 300 million profiles: 300 million × 1 KB = 300 GB

About 300 GB

The row cache: a sharded in-memory cache across a modest cluster, not a single node.

Page builds a second to rebuild all profiles daily

300 million profiles ÷ 86,400 seconds = about 3,500 page builds a second; × 500 heavy scorings per build = about 1.7 million heavy scorings a second. Live ranking at 1 million requests a second × 500 = 500 million a second, about 300 times more

About 3,500 builds a second, roughly 300 times less heavy-model work than ranking live

The precompute-versus-live decision: building ahead is far cheaper, and the saving pays for a light adjustment using fresh signals.

Exploration slots on a page

5% × 50 slots = 2.5; 10% × 50 slots = 5

About three to five titles on a page of about 50

How many slots the final pass reserves for new or under-shown titles.

Event volume into the lake

Assume events arrive at about the home page rate, 1 million a second, at an assumed 200 bytes each: 200 MB a second × 86,400 seconds = about 17 TB a day, so about 6 PB a year before compression

About 17 TB a day, petabytes a year

The data lake and the batch jobs over it: a columnar store with daily partitions, and a retention policy.

Core entities

EntityWhat it holds

Profile

One viewer within an account: the unit the page is personalized for.

Title

A show or film in the catalog, with the metadata the candidate sources and the model use.

Interaction event

One thing a viewer did: a play, a hover, a finish. Appended to the stream and not changed afterward.

Feature

One named value about a profile or a title, kept in an offline store for training and an online store for serving.

Row

A built shelf for one profile: a name and an ordered list of titles, with when and how it was built.

The API

EndpointNotes

GET /v1/home?profile_id=… → [{ row, titles }]

The home service reads the row cache first. If the cached page is older than the profile's latest play, it reranks lightly before answering; on a miss it calls the ranking service, and on a timeout it serves the cached page or the country's popular rows. A field on the response says which path answered, so you can watch the fallback rate.

POST /v1/events { profile_id, title_id, action, at }

The event service validates, appends to the stream and acknowledges. The request carries no id of its own, so in this design a retried send is deduplicated downstream on the combination of profile, title, action and timestamp. A viewer can hover over many titles before playing one, so the client batches hovers and the server may sample them; plays are sent at once.

GET /v1/titles/{id}/similar → titles

Served from a similar-titles table built offline from co-watching and content embeddings. The same table is one of the candidate sources for the home page, so the detail page and the home page start from the same similarity signal, even though ranking and filtering can order them differently.

The high-level design

homemissfeaturesAppHome serviceRanking serviceOnline features

Step 1 of 4

A home service that ranks on request

Start with the read path. The app calls GET /v1/home; a home service asks the ranking service for a page; the ranking service pulls candidates from a few simple sources (titles similar to recent plays, popular in the country, continue watching), reads features for each from an online feature store, scores them, and orders them into rows. It works, and it is the shape to put up first because it shows where the cost lives: each request pays a full ranking pass and a feature read per candidate.

GET homePOST eventshitmisstimeoutretrievefeaturessecondsloadtraining databuild rowsevery fewminutesAppHome serviceEvent serviceRow cacheRanking servicePopular rows bycountryCandidate sourcesOnline featurestoreEvent streamStream featurejobsData lakeBatch featurejobsOffline featurestoreModel training
The whole design

What breaks first

The deep dives

Serving the home page. A viewer opens the app. The page has to be chosen from a catalog of over 10,000 titles, personalized, and on screen fast, at millions of page requests a second. Where does the work happen, and when?

A concept that helps here: Caching strategiesA concept that helps here: Failing open or failing closed

Fresh features. A viewer finishes a show and reopens the home page a minute later. How does the play they just made reach the data the next page is built from, and how do you keep what the model learned from matching what it sees in serving?

A concept that helps here: Feature stores and training-serving skewA concept that helps here: Stream processing and windowsA concept that helps here: Lambda and Kappa architectures

Concepts this guide uses

Sources

  1. Google Machine Learning: Recommendation systems overview
  2. Google Machine Learning: Re-ranking
  3. The Morning Paper: Deep neural networks for YouTube recommendations
  4. Feast documentation: Quickstart
  5. Google: Rules of Machine Learning, best practices for ML engineering
  6. Netflix Hystrix wiki: How it works
  7. Aced: Netflix system design interview
  8. Aced: Meta system design interview
  9. CallSphere: AI system design interview questions 2026
Sign in to report a mistake