KatInterview

Design a Personalized Feed Recommendation Engine

Machine LearningModel answer
HardModel answerMachine Learningrecommendation systemsML system designtwo-tower model

Last updated

Design an end-to-end recommendation system for a large e-commerce platform, covering data pipelines, candidate retrieval, ranking, cold start, and evaluation.

Context

You are a senior ML engineer at an e-commerce company. The product team wants to add a "Just For You" section to the homepage. Your job is to design the full recommendation system that powers it.

Scale:

  • 10 million products in the catalog, with new items added every day
  • 1 million daily active users (DAU), roughly 50 million registered accounts
  • Peak traffic of 10,000 requests per second
  • End-to-end latency budget: under 200ms at p99

What you need to cover

1. Architecture overview Walk through every major component from raw event collection to serving a ranked list. Explain how data flows through the system and where latency is spent.

2. Data model and features What tables or streams do you need? What features do you compute for users, items, and context? How frequently are they refreshed?

3. Retrieval vs. ranking You cannot score all 10 million items per request. Describe the two-stage funnel: what each stage optimizes, what model you use, and how you balance speed against precision.

4. Cold start How does the system behave for a brand-new user with no history? For a product just added to the catalog?

5. Evaluation Propose metrics for both offline evaluation (model quality during training) and online evaluation (live user behavior). How would you run an A/B test to compare two recommendation algorithms?


Constraints and edge cases to address

  • The system must stay within the 200ms latency budget even at peak load
  • New products must be surfaceable before they accumulate interaction data
  • Out-of-stock and policy-violating items must never appear in results
  • The architecture must support running multiple recommendation algorithms simultaneously for experimentation

Hints

Hint 1

Start by estimating event volume and storage needs — those numbers will justify your infrastructure choices and show the interviewer you are reasoning from data, not guessing. For example: 1M DAU × 100 events ≈ 100M events/day, and 10M items × 128-dim float32 embeddings ≈ 5 GB, which fits in memory on an ANN server.

Hint 2

The 200ms budget makes a single-stage approach over the full catalog impossible. Think of the problem as a funnel: a fast, high-recall retrieval stage brings a large candidate set down to ~1,000 items, then a slower, high-precision ranking model scores only those. Sketch out a time budget for each stage (feature fetch, retrieval, ranking, re-rank) that adds up to under 200ms.

Hint 3

Cold start for new items is solved differently from cold start for new users. For items, content-based signals — text embeddings of the product title and image embeddings — give you a useful vector before any clicks exist. For users, lean on session signals and item-to-item retrieval: even 2–3 clicks in a session are enough to start personalizing without a learned user embedding.