System design interview: design a recommendation system

A recommendation system picks, for each user and moment, a short list of items they are likely to want from a catalog far too large to score in full. The standard design is a funnel: cheap candidate generation narrows millions of items to about a thousand, a heavier model ranks those, and a final pass applies diversity and business rules. The interview tests whether you can explain that funnel, the data that feeds it, and how you would know a change made things better.

By Published 7 min read

1. Clarify the requirements

Ask what is being recommended and where. Videos on a home screen, products under a product page and songs in an autoplay queue share the funnel but differ in signals, freshness and what counts as success.

  • Functional: a personalized home feed; "more like this" under an item; recommendations update as the user interacts in a session; hide items the user dismissed or already bought.
  • Non-functional: a feed request returns in roughly 100 to 200 ms; new items become recommendable within hours; new users get reasonable results from the first visit; the system keeps serving (with simpler results) if a model service fails.
  • Define success: agree on the main metric (watch time, purchases, long-term retention) and guardrails (complaints, diversity, latency). This choice shapes the training labels.

2. Estimate the scale

Back-of-envelope estimate for a large consumer app (assumed figures)
QuantityAssumptionResult
Users100 million daily activethe base for the lines below
Feed requests20 per user a day2 billion a day, about 23,000 a second on average
Catalog10 million itemsfar too many to score per request
Ranking work1,000 candidates per requestabout 23 million item scores a second
Item embeddings10 million x 256 floats x 4 bytesabout 10 GB, fits in memory on retrieval servers
User embeddings100 million x 256 x 4 bytesabout 100 GB, kept in a key-value store
Back-of-envelope estimate for a large consumer app (assumed figures). Scroll sideways on a small screen.

The 23 million scores a second is what forces the funnel. A heavy model can afford a thousand items per request; it cannot afford ten million. The method behind figures like these is in capacity estimation.

3. Define the API

GET  /v1/feed?surface=home&cursor=...&context=mobile   -> 200 { items: [{ itemId, reason, requestId }], nextCursor }
GET  /v1/items/{id}/similar?limit=20                    -> 200 { items[] }
POST /v1/events  [{ requestId, itemId, type: impression|click|watch|purchase|dismiss, value, ts }] -> 202
Clients ask for a feed and report what happened; the events are the training data.

The requestId returned with each feed is logged with every later event, so training data can join what was shown with what happened, including items that were shown and ignored.

4. Sketch the data model

Data the funnel reads and writes
DataStoreUse
Interaction eventsDurable log, then a data lake partitioned by dayTraining labels and features; impressions as well as clicks
Item metadataCatalog databaseCategory, creator, price, age, availability, content embeddings
FeaturesFeature store: offline tables plus an online key-value storePer user (recent categories, activity), per item (click rate last 24 h), per pair
EmbeddingsItem vectors in an approximate nearest neighbor (ANN) index; user vectors in a key-value storeCandidate retrieval
Served listsLog of what was shown per requestDebugging, training and offline replay
Data the funnel reads and writes. Scroll sideways on a small screen.

5. Candidate generation: from millions to a thousand

Several cheap sources each propose a few hundred items, and their union becomes the candidate set. Mixing sources keeps results relevant even when one source is weak.

Common candidate sources
SourceHow it worksStrength
Two-tower embeddingsOne network maps users to vectors, another maps items; retrieve the items nearest to the user vector with an ANN index (HNSW or similar)Personal and fast; covers the whole catalog
Item-to-itemItems often consumed together with what the user just viewed (co-occurrence)Strong for "more like this" and in-session
Follows and subscriptionsNew items from creators, artists or shops the user followsExplicit intent
Popular and trendingTop items by region and category in the last hoursCold start and freshness
Fresh itemsA small reserved slice of new uploadsGives new items a chance to collect signals
Common candidate sources. Scroll sideways on a small screen.

Exact nearest neighbor search over ten million vectors per request is too slow, so ANN indexes trade a little recall for a large speed-up. Rebuild or update the index as new items arrive, and filter unavailable items after retrieval.

6. Ranking and re-ranking

  1. Fetch featuresFor each of the thousand candidates, fetch item features and user-item features from the online feature store in one batched call.
  2. ScoreA ranking model (gradient-boosted trees or a neural network) predicts the probability of each outcome you care about: click, long watch, purchase, dismiss. Combine them into one score with weights that reflect the business goal.
  3. Re-rankApply rules the model does not know: remove already-purchased items, limit items per creator, mix categories, insert a few fresh items, respect policy filters.
  4. LogRecord the final list, scores and features used, keyed by request ID, so the next model trains on exactly what served.
request ............................................ 150 ms budget
  load user vector + recent history ................  10 ms
  candidate sources in parallel (ANN, co-views, ...)   30 ms  -> ~1,000 items
  batch feature fetch ..............................  20 ms
  ranking model on 1,000 items .....................  40 ms  -> scored list
  re-rank: filters, diversity, fresh slots .........   5 ms  -> top 50
  network and margin ...............................  45 ms
The funnel with an illustrative latency budget (assumed figures)

7. The architecture

  1. Clients
    • Apps and web
    • Event logging
  2. Online
    • Recommendation service
    • Candidate sources (ANN, co-views, trending)
    • Model server
    • Re-ranker
  3. Features
    • Online feature store
    • Stream feature jobs
  4. Offline
    • Event log and data lake
    • Training pipelines
    • Embedding builds
  5. Release
    • Model registry and validation
    • Experiment assignment
Online serving and offline training loops. Clients request a feed from the recommendation service. It loads the user's vector and recent history, queries several candidate sources in parallel including an ANN index, fetches features from the online feature store, calls a model server to rank the candidates, applies re-ranking rules and returns the list with a request ID. Clients send impression and interaction events to an event log. Stream jobs update fresh features such as recent clicks; batch pipelines join served lists with events, build training sets, train models and embeddings, validate them and publish new versions to the model server and the ANN index.

8. Hard parts worth raising

  • Cold start. New users get popular and regional items plus a short interest picker; their vector updates after a few interactions. New items get content-based embeddings (from text, images or audio) and a reserved exploration slot until they collect signals.
  • Training-serving skew. If "clicks in the last 24 hours" is computed one way in the training pipeline and another way in serving, the model sees different inputs live than it learned from. Define features once in a feature store and log served features.
  • Feedback loops and position bias. Items shown at the top get clicked more because they were at the top. Log positions, correct for them in training, and keep some exploration so the model can learn about items it rarely shows.
  • Fallbacks. If the model server times out, return a cached or popularity-based list rather than an error. A plain feed is better than an empty one.
  • Evaluation. Offline metrics (recall at k, NDCG) screen candidates, but only an online A/B test on the agreed metric decides. Roll out through a feature flag service so the share of traffic per variant is controlled and reversible.

9. What breaks, and trade-offs to discuss

Failure modes worth naming
FailureEffectMitigation
Bad model version shippedEngagement drops for everyoneShadow-score and canary new models; automatic rollback on guardrail metrics
Feature store lagRecommendations ignore the last hour of behaviorMonitor freshness per feature; fall back to session history from the request
ANN index staleNew items never appearIncremental updates plus a fresh-items source that bypasses the index
Popular item goes out of stockUsers see things they cannot buyAvailability filter at re-rank time, reading current stock
Failure modes worth naming. Scroll sideways on a small screen.
  • Precompute or compute per request. Nightly lists per user are cheap and fast to serve but ignore what the user just did; per-request scoring reacts to the session at a higher cost. Many systems blend a precomputed base with live re-ranking.
  • One model or several. Separate models per surface fit each better but multiply training and monitoring work.
  • Short-term clicks or long-term value. Optimizing for clicks can promote clickbait; weighting completions or return visits aligns better with satisfaction.
  • Relevance or diversity. A list of near-identical items scores well per item but feels repetitive; re-ranking for variety costs a little predicted relevance.

10. How to talk through it in the interview

Fictional example

Answering the cold-start follow-up
Interviewer
A new user signs up. What do they see?
Candidate
First, popular items in their region and language, plus a quick picker of a few interests. As soon as they interact, item-to-item candidates from what they touched start to dominate, and after a few dozen events their user vector from the two-tower model is good enough to drive retrieval.
Interviewer
And a brand-new item nobody has seen?
Candidate
It gets an embedding from its content, so retrieval can find it for users who like similar items, and a small exploration slot shows it to some users so it can collect clicks quickly.
  • Draw the funnel and the offline loop as two separate pictures.
  • Put a number on each funnel stage, using your estimate.
  • Mention how you would measure success before the interviewer asks.

Recommendations also power personal sections in other prompts, such as the "for you" area of a news aggregator, and query understanding overlaps with a search engine, where ranking takes a query instead of a user as input.

Practicing this design with Natively

This prompt mixes infrastructure and machine learning, and interviewers often pull you toward whichever side you know less. Practice with a partner who switches between the two. Natively, running on your computer during the call, writes a live transcript of both voices and can offer talking points for the current question when you press the shortcut, for example position bias or training-serving skew. Ask it for a diagram of the funnel to check your structure. The saved notes show which follow-ups you answered with a mechanism and which with a buzzword.

Questions people ask

How do you design a recommendation system in an interview?

Describe a funnel. Several cheap candidate sources, such as embedding search, co-viewed items and trending items, narrow millions of items to about a thousand. A ranking model scores those with fresh features, and a re-ranking step applies diversity and business rules. An offline loop trains models from logged impressions and interactions.

What is candidate generation in a recommender system?

It is the first, cheap stage that picks a few hundred to a few thousand plausible items out of the whole catalog. Common sources are nearest-neighbor search over user and item embeddings, items often consumed together, new items from followed creators, and popular items in the user's region.

How do you handle cold start for new users and new items?

New users start with popular and regional items plus a short interest picker, and their profile updates after a few interactions. New items get embeddings from their content so retrieval can find them, plus a small exploration slot that shows them to some users until they gather signals.

How do you know a new recommendation model is better?

Offline metrics such as recall at k or NDCG on held-out data screen candidates, but the decision comes from an online A/B test on the agreed business metric with guardrails such as complaints and latency. Roll the new model out to a small share of traffic first and roll back automatically if guardrails slip.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP