Pick the few items worth showing out of millions: candidates, ranking, fresh feedback and cold start.
“Design a content recommendation system, like the home page on YouTube or Netflix.”
It is short on purpose. Your first job is to make it specific.
| What they check | Why it matters |
|---|---|
| Scoping a broad prompt | “Recommendations” can mean a model, a pipeline, a UI, or a whole company. A strong candidate says which part they design (the system that retrieves, ranks, learns and serves) and what they leave out. |
| The funnel idea | You cannot score 100 million items per request. Cheap retrieval, then a heavier ranker, then re-ranking is the core answer. The interviewer wants the numbers that force it. |
| Data and feedback loops | What you log (especially what was shown) decides what you can learn. Training and serving must see the same features. The system also trains on its own output, which biases it. |
| Cold start and freshness | New users and new items have no history. A design that only works for warm users and old items fails the first follow-up. |
| Operating a learning system | Models drift, deployments go wrong quietly, and offline metrics lie. Experiments, guardrails, fallbacks and cost are part of the design. |
Recommendations are a funnel: from 100 million items, a few cheap retrievers pick about 2,000 candidates, a small model trims them, a heavier ranker scores a few hundred, and a re-ranker adds variety and rules to give the 30 items shown. All of it must finish in about 200 ms.
| Step | Minutes | What to get done |
|---|---|---|
| 1. Clarify | 4 | Scope hard: home page only. Objective, scale, freshness, cold start, what is out. |
| 2. Estimate | 3 | Requests per second, events per second, embedding size, candidates times requests. |
| 3. API and data | 4 | Get recommendations, log events. Interactions, features, embeddings, models. |
| 4. High-level design | 8 | Online funnel and offline training loop. One request, one event. |
| 5. Deep dives | 16 | The funnel and budget, embeddings and nearest-neighbour search, features and feedback, cold start, experiments. |
| 6. Scale and failures | 7 | Feature store down, slow ranker, bad model, cost, privacy deletion. |
| 7. Wrap up | 3 | Recap, trade-offs, what you would build first. |
| Ask | Why you ask it | Typical answer | How it changes the design |
|---|---|---|---|
| Which surface: the home page, an “up next” list, search results, or all of them? | Each has different inputs and latency. Search has a query. Up next has a current item. Home has only the user. | The home page for logged-in users. “Up next” uses the same engine with a seed item. | One service with a surface parameter. Home is the main design. |
| What is the goal: clicks, watch time, or something harder to measure like satisfaction? | The objective shapes labels, the model and the failure modes (clickbait). | Long-term engagement, approximated by watch time with guardrails for satisfaction and variety. | The ranker predicts several outcomes and a blend score. Guardrail metrics are part of every experiment. |
| How many daily users, how big is the catalog, and how often do new items arrive? | Decides whether we can score everything and how fresh the index must be. | 200M daily users, 100M items, about 100,000 new items a day. | Scoring everything is impossible. A funnel is required, and new items need a fast path. |
| How many home-page requests and how many feedback events a day? | Sets serving and logging capacity. | About 5 requests per user per day, and about 100 events per user per day. | About 50,000 requests a second at peak, and about 1 million events a second at peak. |
| What is the latency target? | It fixes the budget for retrieval plus ranking. | Under 200 ms at p99 for the response, with a cheaper fallback if something is slow. | A stage-by-stage time budget, timeouts, and a popularity fallback. |
| How fresh must recommendations be? If I watch a video, when should the next page change? | Decides whether we need streaming features or only a nightly job. | Within a few minutes for recent activity. New items should appear within an hour. | A nearline path (stream processing) for recent-activity features and a small real-time index for new items. |
| What about new users and new items with no history? | Cold start is where simple designs break. | Both must work from day one, in a reasonable way. | Popular and context-based fallback for users, content features and exploration for items. |
| Do I design the model itself, or the system around it? | Prevents an hour of model theory. | The system: retrieval, features, serving, logging, training pipeline, experiments. Treat models as black boxes with a known input and output. | We name model types, but spend time on data flow, latency and operations. |
| Are there safety, region and policy rules? | Filters must run in the pipeline, not only in the model. | Yes: age ratings, regional licensing, blocked content, and user “not interested” signals. | Hard filters before ranking and a policy check after re-ranking. |
| Is video delivery, search, ads or moderation part of this? | Scoping out loud saves time and shows judgement. | No. Video delivery, search and ads are separate systems. | We link them and leave them out. |
| Assumption | Value |
|---|---|
| Daily active users | 200 million |
| Home-page requests per user per day | 5 |
| Feedback events per user per day (clicks, plays, watch pings, likes) | 100 |
| Catalog size, new items per day | 100 million items, about 100,000 new a day |
| Peak compared to average | 4 times |
| Average event size in the log | 100 bytes |
| Embedding | 128 numbers, 4 bytes each (float32) |
| Candidates after retrieval, and kept for the heavy ranker | about 2,000, trimmed to about 500 |
| Features per scored item | about 50 |
| Items returned per request | 30 |
| What | Maths | Result |
|---|---|---|
| Requests per day | 200M × 5 | 1 billion |
| Requests per second (average, peak) | 1B ÷ 86,400 ≈ 11,600, × 4 | about 12,000 and 46,000 (call it 50,000) |
| Events per day | 200M × 100 | 20 billion |
| Events per second (average, peak) | 20B ÷ 86,400 ≈ 231,000, × 4 | about 230,000 and 925,000 (call it 1 million) |
| Event log per day, per year with 3 copies | 20B × 100 B = 2 TB; × 365 × 3 | 2 TB a day, about 2.2 PB a year with copies (plus about 0.6 TB a day for the lists of items shown) |
| Log ingest bandwidth (average, peak) | 231,000 × 100 B; 925,000 × 100 B | about 23 MB/s and 93 MB/s (about 10 partitions at 10 MB/s, so plan for 30 or more) |
| User embeddings | 200M × 128 × 4 B | about 102 GB (about 26 GB at 1 byte per number) |
| Item embeddings | 100M × 128 × 4 B | about 51 GB (about 13 GB at 1 byte per number) |
| Scoring everything per request (not possible) | 100M items × 46,000 requests a second | 4.6 trillion scorings a second, so a funnel is required |
| Heavy ranker work with 2,000 candidates | 2,000 × 46,000 | 92 million scorings a second, and 2,000 × 50 = 100,000 feature values per request |
| Heavy ranker work after trimming to 500 | 500 × 46,000 | 23 million scorings a second, 25,000 feature values per request |
| Nearest-neighbour queries and nodes | 46,000 queries a second ÷ 2,000 per replica (assumed) | about 23 replicas, so about 25 of the item index |
| Method | Path | Request | Response | Notes |
|---|---|---|---|---|
| GET | /v1/recommendations?surface=home&n=30&cursor= | none | 200 { requestId, modelVersion, items: [{ itemId, position, reason }], nextCursor } | Auth required. requestId and modelVersion are for logging and debugging. The cursor holds a session seed so page 2 continues the same ranking. Falls back to a popular list rather than an error. |
| POST | /v1/events | { events: [{ type, itemId, position, requestId, ts, watchMs? }] } | 202 | Batched from the client, idempotent by (userId, eventId). Types: impression_seen, click, play, watch_progress, like, not_interested. Always carries requestId and position. |
| POST | /v1/feedback/not-interested | { itemId | channelId } | 204 | Applied immediately to a per-user block set that the filters read, and also sent as a training signal. |
| GET | /internal/candidates/{source}?userId=&limit= | none | 200 { itemIds[], scores[] } | Internal. One endpoint per retriever. Called in parallel with a tight timeout. |
| POST | /internal/rank | { userContext, itemIds[] } | 200 { scores[] } | Internal model server call. Batches many items per call and returns within a deadline. |
| Store | Key and value | Notes |
|---|---|---|
| Interaction log | append-only events: (user, item, type, position, requestId, ts, watchMs) | Kafka, then a data lake in a columnar format. The source of truth for training. About 2 TB a day. |
| Exposure log | requestId → user, modelVersion, list of (item, position) | Written by the serving system when it responds. Needed for “already seen” filters and unbiased training. |
| Online feature store | user:{id} and item:{id} → feature values, with freshness timestamps | Key-value, low latency. Recent-activity features are updated by a stream job within minutes. |
| Offline feature store | the same feature definitions, as tables with history | Used to build point-in-time-correct training sets, so there is no leakage from the future. |
| Embeddings and ANN index | user vector, item vector, approximate nearest-neighbour index, all with a model version | Item index sharded and replicated, rebuilt on a schedule plus a small real-time index. |
| Model registry | model name, version, training data range, metrics, status | Controls which version serves which share of traffic. Supports instant rollback. |
| Item catalog and policy | item metadata, region, age rating, status | Source for filters. Cached in memory by the serving system. |
label = watched >= 30s? (or expected watch time)
features = user features AS OF the request time <- point-in-time, not today's values
+ item features AS OF the request time
+ context (device, hour, position shown)
requestId = joins the impression to later clicks and plays
modelVersion = which model chose this list (to correct for its own bias later)| Component | What it does |
|---|---|
| Recommendation API | Applies the time budget, calls the stages with timeouts, logs the exposure, and returns a popular fallback list if anything fails. |
| Retrievers | Several cheap sources run in parallel: nearest neighbours of the user vector, items similar to recent watches, trending by region, new items from subscriptions. |
| Filters and light ranker | Remove what must not be shown (already seen, blocked, region, age rating), merge and de-duplicate, then trim about 2,000 to about 500 with a small model. |
| Heavy ranker | A model server scores the 500 with user, item and context features, predicting watch time and click probability, then blends them into one score. |
| Re-ranker | Adds variety (not five from one channel), freshness, policy rules and a small exploration share, then cuts to 30. |
| Online feature store | Low-latency features by key. Recent-activity values are refreshed by stream jobs within minutes. |
| Embedding indexes | A large approximate nearest-neighbour index rebuilt on a schedule, and a small index of new items updated within minutes. Both carry the model version. |
| Event log, stream jobs, data lake | Everything the user does is logged once, used in minutes for fresh features, and kept for batch training. |
| Training, registry and experiments | Models are trained on a schedule, evaluated offline, canaried, A/B tested, and only then promoted. Rollback is one switch. |
The problem: We have 100 million items and 200 ms. The invariant is: every item shown was either retrieved by some source or put there on purpose (exploration), and the whole request returns something useful even if a stage is slow or down.
| Option | How it works | Good | Bad |
|---|---|---|---|
| Score everything with one model | Run the best model on every item for every request. | No recall loss, one model to maintain. | 4.6 trillion scorings a second. Impossible. |
| Precompute lists offline | A nightly job computes the top 30 per user and stores it. | Instant reads. Cheap at serving time. Easy to reason about. | Stale (does not react to what you just watched). Storage and compute for users who never return. No context such as the hour or device. |
| Two stages: retrieve, then rank | Cheap sources give about 2,000 candidates and one model ranks them. | The standard shape. Bounded cost per request. | The ranker sees only what retrieval gave it. 2,000 is still 92 million scorings a second. |
| Retrieve, trim, rank, re-rank (funnel) | Parallel retrievers, a light model trims to about 500, a heavy ranker scores them, a re-ranker applies variety and policy. | Each stage is as cheap as its job allows. Time budgets and fallbacks per stage. Quality can be improved stage by stage. | More parts to run and monitor. Errors compound: an item dropped early is gone for good. |
The funnel is the only option that fits the cost. The important rule is that each stage can only choose among what the previous one passed on. A great ranker cannot recover an item the retrieval stage dropped, so recall at retrieval is the quality ceiling for the whole system. That is why we run several different retrievers in parallel (similar to the user, similar to recent watches, trending, subscriptions) rather than one very good one: they find different kinds of good items.
Give every stage a time budget and a fallback. For example: load user context 15 ms, retrieval 40 ms (the slowest retriever, with a hard timeout), filters and light ranking 25 ms, heavy ranker 60 ms, re-rank 10 ms, logging and response 10 ms. That is 160 ms and leaves 40 ms of slack for the p99 tail. If a retriever is late we skip it. If the heavy ranker is late we return the light-model order. If everything fails we return a cached or popular list. A precomputed list for the most active users (refreshed every few minutes) both saves compute and gives a ready fallback, at the cost of some staleness.
| Stage | Input to output | Budget | If it is slow or down |
|---|---|---|---|
| User context | user id to features and vector | 15 ms | Use a cached copy, or treat the user as new |
| Retrieval | 100M to about 2,000 | 40 ms | Skip the late retriever, keep the others |
| Filters and light rank | 2,000 to about 500 | 25 ms | Skip the light model, filter only |
| Heavy rank | 500 to ordered 500 | 60 ms | Use the light-model order |
| Re-rank | 500 to 30 | 10 ms | Simple rules only (no variety search) |
| Log and respond | write the exposure | 10 ms | Log asynchronously, never block |
The problem: We must find, in about 20 ms, the few hundred items out of 100 million that are closest to a user, and new items must be findable within minutes. The invariant is: the user vector and the item vectors must come from the same model version, or the distances mean nothing.
| Option | How it works | Good | Bad |
|---|---|---|---|
| Exact nearest neighbours | Compare the user vector with every item vector. | Perfect recall. | 100 million comparisons of 128 numbers per request. Far too slow. |
| Tree or hash based approximate search | Split the space into cells (IVF) or hash similar vectors together (LSH) and search only a few cells. | Fast, simple to build, easy to shard. | Recall drops if the cells are cut badly. Needs tuning of how many cells to probe. |
| Graph based approximate search (HNSW) | Build a graph where each vector links to near neighbours and walk it towards the query. | Very good recall and speed in memory. | Memory heavy (links plus vectors). Slow to rebuild. Deletes and updates are awkward. |
| Compressed vectors (product quantisation) | Store each vector in about 16 bytes by coding parts of it, and search on the compact form, often with a re-check of the top results. | 100 million vectors in about 1.6 GB instead of 51 GB. Fits on one machine. | Lower accuracy. Training the codebooks is a step. Usually combined with IVF or a re-check. |
Approximate search trades a little recall for a huge speed gain. At 100 million items and 128 numbers each the raw vectors are 51 GB, or about 13 GB at one byte per number, so the index fits in memory across a handful of machines. We split it into shards of a few million items. Each query goes to every shard and the best results are merged, so the shard count is a latency and cost lever: more shards means smaller, faster searches but more calls per request (46,000 requests a second times 8 shards is about 370,000 shard calls a second).
New items need a different path. Rebuilding the big index takes hours, but a new video should be recommendable within minutes. A small second index (for example, the last day's items, tens of thousands of vectors) is cheap to rebuild or update constantly, and at query time we search both and merge. The item vector for a brand-new item comes from its content (title, tags, thumbnail, channel) because it has no watch history yet.
The versioning rule is strict. A new embedding model changes what every number means. User vectors, item vectors, the index and the ranker features that use them must be switched together under one model version. Mixing versions does not crash anything: the results just quietly get worse.
| Choice | Memory for 100M items | Notes |
|---|---|---|
| float32 vectors, 128 numbers | 51 GB | Raw vectors only, before the search structure |
| 8-bit numbers (scalar quantisation) | 13 GB | Small loss of accuracy, simple, 4 times smaller |
| Product quantisation, 16 bytes per vector | 1.6 GB | About 30 times smaller, lower accuracy, often re-checked with larger vectors |
| Graph links, 32 per item at 4 bytes | 13 GB extra | On top of the vectors, for a graph index |
The problem: The model is only as good as the data it learns from, and that data is produced by the system itself. The invariant is: the features used in training must equal the features the model sees when serving, as of the same moment.
| Option | How it works | Good | Bad |
|---|---|---|---|
| Compute features separately offline and online | A data team builds training tables and engineers rewrite the same logic in the serving code. | Each side can be tuned for its job. | Two versions of every feature drift apart. This is training and serving skew, and it is the most common silent bug. |
| One feature definition, two stores | Define each feature once. A pipeline writes it to an offline table (with history) and to an online key-value store. | Same logic in both places. Point-in-time correct training data is possible. | A feature store platform to build and run. Backfills are costly. |
| Compute everything in the request | Calculate features from raw events when the request arrives. | No staleness. | Far too slow for hundreds of features and 2,000 items. |
| Log the features at serving time | Write the exact feature values used for each request, and train on those logs. | Zero skew by construction, no leakage. | Big logs (features times items times requests). Cannot add a new feature to old data without a backfill. |
The two stores share one definition, so a feature like “watch time in the last 7 days” is computed by the same code for training and serving. To build a training row we must use the value as it was at the time of the request (a point-in-time join), never today's value. Using today's value leaks the future into the past and gives wonderful offline numbers and poor real ones.
Features come at three speeds. Slow ones (long-term taste, item quality) are batch jobs and refresh daily. Medium ones (recent activity, item click rate in the last hour) come from stream jobs and refresh in minutes. Request-time ones (device, hour, position) are free. Labels are tricky: a click is quick, but watch time arrives later, and a short watch may mean “bad” or “wrong moment”. We wait for a window, then label, and use stronger signals (long watches, likes, repeat visits) together with negative ones (skips, “not interested”).
The loop has a trap. We only get feedback on what we showed. Items at position 1 get far more clicks than items at position 10, so a model trained on raw clicks learns that position-1 items are good. Log what was shown and where (the exposure log), train with position as a feature that is set to a fixed value at serving time or corrected for, and keep a small random or exploratory share so the data includes items the model would not have chosen.
| Bias or trap | What happens | Mitigation |
|---|---|---|
| Position bias | Top slots get more clicks regardless of quality | Log position, correct for it in training, test with randomised slots |
| Exposure bias | We never learn about items we did not show | Exploration share, retrieval from several sources |
| Popularity feedback loop | Popular items get shown, so they get more clicks, so they get shown | Normalise by exposure, add a novelty boost, exploration |
| Label leakage | Features computed with data from after the request | Point-in-time joins only |
| Delayed labels | Watch time is known minutes later | Label windows, incomplete-label handling, refresh the model on a schedule |
| Clickbait objective | Clicks rise, satisfaction falls | Predict watch time and satisfaction, use guardrail metrics |
for each request:
top = ranked list (30)
if user is in exploration group:
pick 2 slots (not the first three) and fill them with
items that have few impressions, chosen by uncertainty
(e.g. a bandit: score + bonus for being uncertain)
log which slots were exploratoryThe problem: A new user has no history and a new item has no views, yet both must be handled well. The home page must also be varied enough that it is not ten near-identical items, and we must spend a little engagement to learn about new items.
| Option | How it works | Good | Bad |
|---|---|---|---|
| Popular for everyone | Show the globally popular list to cold users and ignore new items until they get views. | Trivial, safe. | Poor first impression. New items never get views, so they never become popular (a deadlock). |
| Content and context based | For users: device, country, language, onboarding picks. For items: embeddings from title, tags, thumbnail and channel. | Works from the first request. Gives each new item a place in the space. | Weaker than behaviour-based signals. Needs a content model. |
| Exploration budget | Reserve a few slots for items with little data, chosen by uncertainty (a bandit), and measure how they do. | Solves the new-item deadlock. Produces unbiased training data. | Costs some engagement. Needs careful measurement. |
| Re-ranking for variety | After ranking, pick the final list so that no topic or channel dominates (for example, a maximum of two per topic, or a marginal-relevance pass). | A better page, and protection against filter bubbles. | Reduces the model's top-line score a little. Needs tuning. |
A new user is handled by falling back through layers: onboarding picks if they gave any, then context (country, language, device, time of day), then regional popular items, adapting after the first few clicks because recent-activity features update within minutes. A new item gets a content embedding and enters the small fresh index, so it can be retrieved on day one.
Exploration needs a budget, and the budget is smaller than people expect. New items arrive at about 100,000 a day. If each needs about 1,000 impressions to get a stable estimate, that is 100 million impressions a day, out of about 30 billion shown (1 billion requests with 30 items), roughly 0.33%. So an exploration share of 1% is plenty. Two slots out of 30 (6.7%) would cost up to about 4% of expected engagement if those items perform at 40% of normal, and would buy far more learning than needed. Place exploratory items below the first few slots and measure them as their own group.
The re-ranker finishes the job: a cap per topic and per channel, a freshness nudge, hard policy rules (age rating, region, safety checks, “not interested”), and a final check that nothing blocked slipped in from a late stage.
The problem: A new model that looks better offline can be worse in production, and a bad deployment hurts millions of users in seconds. The invariant is: no model reaches all users without passing an online experiment, and any model can be rolled back immediately.
| Option | How it works | Good | Bad |
|---|---|---|---|
| Ship when offline metrics improve | Compare AUC or NDCG on a held-out set and deploy the winner. | Fast, cheap. | Offline metrics ignore the feedback loop and position bias. Models that win offline often lose online. |
| Shadow mode | Run the new model on live requests but do not show its output. Compare the lists and the latency. | Safe. Catches crashes, latency and big list differences. | Cannot measure user behaviour, because users do not see its output. |
| Canary then A/B test | Show it to 1% to 5% of users, check guardrails, then run a proper experiment against the current model on a larger share. | Measures real behaviour. Limits the blast radius. | Takes days, needs enough traffic, and assignment must be stable. |
| Interleaving | Mix results from two models into one list and see which items get clicked. | Needs much less traffic to detect a difference. | Measures preference between lists, not long-term effects. Used as a first filter, not the last word. |
Offline metrics answer “is this model plausible?”. Only an online test answers “is it better for users?”. Use a stable assignment (hash the user ID with the experiment name), so a user stays in one group. Measure the main metric (for example watch time per user) and the guardrails (return rate, satisfaction surveys, share of content from new creators, latency, error rate). With high variance in watch time, detecting a 0.5% change needs about 2.5 million users per group by a rough power rule, which is about a day at 5% of 200 million users, so the test must run long enough to cover weekly cycles and the novelty effect.
Operations matter as much as the model. Watch for drift (feature distributions, embedding norms, score distributions), data pipeline failures (a stale feature that is silently zero), serving latency, and cost (accelerator or CPU hours per million requests). Cost levers are batching, smaller or distilled models, 8-bit numbers, caching the top of the funnel, and precomputing for heavy users. A 5% canary is about 2,300 requests a second, enough to see a problem within minutes.
A teaching model with a fixed 60-title catalog and no random numbers. “Loved” titles come from a hidden score the system never sees. The latency model is made up: retrieval 20 ms + 0.005 ms per real candidate, features 0.015 ms per candidate (0.005 for the cheap ranker), ranking 0.03 ms per candidate (0.01 cheap), re-rank 8 ms, other 20 ms. Real numbers depend on hardware, batching and the model.
| Bottleneck | Fix |
|---|---|
| Heavy ranker compute (about 23 million scorings a second after trimming) | Batch many items per call, trim harder with the light model, use 8-bit numbers or a distilled model, cache scores for hot items briefly, and add model-server replicas. |
| Online feature store reads (about 25 million item lookups a second before caching) | A local in-process cache for item features (items repeat across requests), batched multi-gets, and replicas. A 90% cache hit rate leaves about 2.5 million store reads a second. |
| Nearest-neighbour index memory and fan-out | Compress vectors, shard the index, keep each shard in memory, and balance shard count against the number of calls per request. |
| Event ingestion (about 1 million events a second at peak) | Batch on the client, partition Kafka by user, scale consumers, and use back pressure. Impressions are the bulk, so sample them for non-critical uses. |
| Cost of the heaviest users | Precompute and cache the first page for the most active users, refreshed every few minutes, so their repeat visits cost almost nothing. |
| Tail latency from the slowest stage | Hard timeouts per stage, hedged calls to a second replica, and the fallback ladder: skip the late retriever, use the light order, then a cached or popular list. |
| Index and model rebuild time | Versioned bundles built offline, a fresh-items side index for the gap, and blue-green swaps of the whole bundle. |
| Failure | How the design copes |
|---|---|
| The online feature store is down or slow | Use the local cache and stale copies, fall back to context-only features, and drop to the light model or a popular list. Alert on the share of requests served by fallback. |
| A retriever or the ranker times out | Skip that retriever and use the others, or use the light-model order. The user gets a slightly worse list, not an error. |
| A bad model is deployed | A 5% canary with guardrails shows it within minutes. Roll back with one switch in the model registry. Keep the previous bundle warm. |
| The event pipeline lags or a feature job fails silently | Each feature carries a freshness timestamp, and the serving code treats a stale value as missing. Alert on freshness and on a feature suddenly becoming all zeros. |
| Embedding and ranker versions get out of sync | Ship them as one versioned bundle. The API checks that all stages report the same model version, and refuses to serve a mixed set. |
| A region fails | Another region serves, with slightly stale features and indexes (replicated asynchronously). The page loads; the personalisation is a little behind. |
A request loads the user's features and vector, calls several retrievers in parallel for about 2,000 candidates, filters and trims to about 500 with a light model, scores them with a heavy ranker in one batched call, and re-ranks for variety, policy and a little exploration to return 30 items in under 200 ms, with a fallback at every stage. Every impression and click is logged with a request ID and position, flows through Kafka to fresh features within minutes and to a data lake for training. Models and embeddings ship as versioned bundles through shadow, canary and A/B tests, with instant rollback.
| Decision | What we gain | What it costs |
|---|---|---|
| A multi-stage funnel | Bounded cost per request and room to improve each stage. | More moving parts, and an early drop is permanent. |
| Several retrievers, merged | Higher recall, because each finds a different kind of good item. | More calls per request and a merge step to tune. |
| One feature definition for training and serving | No training and serving skew. | A feature platform to build, run and backfill. |
| Exploration budget | New items and unseen tastes get learned about. | A small, measured loss in short-term engagement. |
| Precompute for heavy users | Lower cost and a ready fallback. | Staler lists and extra storage and refresh work. |
| A/B tests as the final judge | Real user impact, not offline guesses. | Slower iteration and a lot of experiment infrastructure. |
Interviewers start with one request end to end, then push on cost and latency.
A change in requirements is a test of whether you understand why your design looks the way it does.
| New requirement | What changes in the design |
|---|---|
| Add search: results for a typed query, personalised | A different entry point. Retrieval comes from the search index (see Design a Search Engine), the ranker adds query features, and the personalised score blends in. The feature store and event loop are shared. |
| An “up next” list after a video ends | Seed item as an input. Retrieval leans on item-to-item similarity and the current session, latency is tighter, and the list can be precomputed for popular seeds. |
| Add a short-video feed with endless scroll | Many small requests, so the first batch is ranked heavily and later batches are cheap. Session-sequence features and fast feedback matter more. Prefetch the next batch. |
| Add ads into the same list | A separate auction produces candidates with bids. The re-ranker merges them under rules for spacing and quality, with its own latency budget and logging. |
| The catalog becomes 10 times larger | Shard and compress the index, use hierarchical retrieval (cluster first), and spend more effort on the fresh-item path. The funnel shape does not change. |
| A strict privacy mode with no personal history | Use context and on-device signals, with aggregate popular and content-based retrieval on the server. Measure the quality loss and show users the trade-off. |
| Real-time re-ranking after every click | A light session model in the request path, fed by a very fast stream of recent actions. More state to keep consistent and a tighter budget, so keep it small and cache aggressively. |
| Area | Weak | Good | Great |
|---|---|---|---|
| Scoping | Starts drawing a model. Never says what is included. | States the surface, scale and objective, and what is out of scope. | Scopes hard in two minutes, names guardrail metrics, and says it will treat models as black boxes. |
| Estimation | No numbers, or numbers that do not change the design. | Requests, events and vector sizes, and notices the catalog is too big to score. | Shows 4.6 trillion scorings a second forces a funnel, and sizes the ranker, feature store and index from it. |
| Design | One model and one database. | Retrieve then rank, with a feature store and an event log. | A funnel with budgets and fallbacks, versioned bundles, a fresh-item index, and a clear online and offline split. |
| Data and feedback | Logs clicks only. Ignores skew and bias. | Logs impressions, point-in-time features, and names position bias. | Explains the feedback loop, exploration budget, delayed labels and how skew is prevented by one feature definition. |
| Operations | Ships on offline metrics. No rollback. | A/B tests and a fallback list. | Shadow, canary, guardrails, drift and freshness monitoring, instant rollback, cost control and deletion handling. |
| Communication | Jargon without explanation. | Explains embeddings and the funnel simply. | Uses the numbers, names trade-offs aloud, and admits what is uncertain. |
| Mistake | Do this instead |
|---|---|
| Designing the model instead of the system | Scope it out loud: models are black boxes with inputs and outputs. Spend the time on data flow, latency and operations. |
| Scoring the whole catalog, or never doing the maths | Show 100 million items times 46,000 requests a second. Let the number force the funnel. |
| Logging clicks but not impressions and positions | Log every exposure with request ID, item and position. Without it you cannot train fairly. |
| Ignoring training and serving skew | One feature definition feeding both stores, point-in-time joins, and monitoring of live feature distributions. |
| Forgetting cold start and new items | Context for new users, content embeddings and a fresh index for new items, plus a small exploration budget. |
| Shipping on offline metrics alone | Offline is a filter. Use shadow, canary and an A/B test with guardrails. |
| Mixing model versions | Ship user vectors, item vectors, the index and the ranker as one versioned bundle, and check versions at serve time. |
| No fallback | Every stage has a timeout and a cheaper answer, ending at a cached or popular list. |
Same two-stage idea (candidates then ranking) for a social feed, with fan-out as the main problem.
The delivery side of what you recommend, and the source of the watch-time signal.
Retrieval and ranking for a typed query, with the same funnel shape.
How embeddings are stored and searched by similarity.
Offline and online feature stores and how they avoid skew.
How experiments are assigned, measured and read safely.
The event log that carries impressions and clicks.
Deleting a user's history, features and embeddings.