KatInterview

Build a Nearby-Restaurant Ranking Pipeline for an App Homepage

Machine LearningModel answer
HardModel answerMachine Learningrecommender-systemscandidate-generationranking

Last updated

Design a sub-100ms ML pipeline that picks and ranks open, deliverable restaurants for each user's homepage carousel, covering retrieval, ranking, cold start, and evaluation.

You are building the personalized carousel at the top of a meal-delivery app's home screen. For each user, it should show the restaurants they are most likely to order from right now.

Requirements

  • Latency: the whole request must finish in under 100 ms (p99).
  • Eligibility: every restaurant shown must be currently open and accepting orders, and a courier must be able to reach the user's location (inside the delivery zone or radius).
  • Scale: millions of daily active users, tens of thousands of restaurants, and heavy request throughput with a dinner-time peak.
  • Business goals: relevance alone is not enough. The ranking should also consider delivery fees, delivery-time estimates, and the capacity of the courier fleet.

What to cover

  1. End-to-end architecture: how a request flows to a final ranked list, including a latency budget per stage.
  2. Candidate generation: how you use the spatial constraint to shrink the restaurant pool, and which retrieval strategies you combine.
  3. Ranking: model choice, training labels, features (user history, restaurant popularity, time of day, logistics), and how you handle new users and new restaurants.
  4. Evaluation: offline and online metrics, plus guardrails.

State your scale assumptions, discuss the main trade-offs, and be explicit about what you would ship first versus later.

Hints

Hint 1

Start with the constraint: after filtering by delivery zone and open status, a user typically has only hundreds to a couple thousand eligible restaurants. How does that change your retrieval design (do you even need a global ANN index)?

Hint 2

Treat eligibility as a hard filter before any model runs, and split the 100 ms budget across stages (filter, retrieval, feature fetch, ranking, re-ranking, headroom) so each component has a number to hit.

Hint 3

Think about what the ranker should optimize: expected orders and value per impression minus a logistics cost, not just CTR. Then think about position bias in logged data, cold start for new users and new restaurants, and marketplace guardrails such as ETA and courier utilization.