KatInterview

Design a Product Discovery and Ranking Platform

Machine LearningModel answer
HardModel answerMachine Learningsearchrankinginformation-retrieval

Last updated

Design an end-to-end search system for a large online marketplace, covering query understanding, retrieval, ranking, indexing pipelines, and serving infrastructure.

Scenario

You are a senior ML engineer at a large online marketplace with hundreds of millions of listed items. The team wants to rebuild the product discovery experience from the ground up.

Shoppers type natural-language queries like noise cancelling headphones under $80, optionally narrow results with filters (price range, brand, average rating, availability), and expect a tight, well-ranked list of relevant items back within a fraction of a second. The catalog is enormous, prices and stock levels shift constantly, and the same query should feel slightly different for a power user who always buys Sony versus a first-time visitor.

Your Task

Walk through the full system design. You are expected to cover:

  1. Requirements — what the system must do (functional) and how well it must do it (non-functional). Put concrete numbers on scale: catalog size, query volume, acceptable latency, and freshness targets.
  2. Query-time flow — trace a search request from the moment it leaves the browser to the moment ranked results arrive back, naming every major processing stage.
  3. Catalog ingestion and indexing — how new listings, price updates, and stock changes flow into the index, and why they may need to be treated differently.
  4. Retrieval strategy — when to use keyword-based retrieval, when to use embedding-based semantic retrieval, and how to combine them.
  5. Ranking model — architecture choices, the feature groups you would engineer, the training signal you would use, and one important training pitfall to avoid.
  6. Serving architecture — caching strategy, how you would scale to holiday traffic spikes, and how the system degrades gracefully when a component is slow or down.
  7. Evaluation — at least two offline metrics and two online metrics, and what each one actually tells you.
  8. Trade-offs — pick two meaningful tensions in this design (e.g., freshness vs. cost, recall vs. latency) and explain how you would resolve them.

There is no single correct answer. Interviewers are looking for clear reasoning, concrete numbers, and honest acknowledgment of trade-offs.

Hints

Hint 1

Start by splitting the problem into two clearly separate concerns: getting a manageable candidate set quickly (retrieval, optimizing for recall) and then scoring that set precisely (ranking, optimizing for precision). Many candidates collapse these into one step and get stuck on latency.

Hint 2

Price and stock are written orders of magnitude more often than product descriptions. Ask yourself whether it makes sense to reindex a full document every time a price changes by $0.01, or whether you can decouple fast-changing fields from slow-changing ones.

Hint 3

Your ranking model is trained on historical click and purchase logs, which reflect the order your old ranking showed items — not the true relevance of items. Think about what goes wrong if you train directly on logged positions, and how you would correct for it.