← All problems
Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Problem 038 · Fundamentals and estimation

Design a Recommendation Service

Medium 50 min

An online retailer wants a 'You may also like' row on product and home pages. It has 30 million daily active users and 5 million products, and at peak the pages ask for about 12,000 recommendation lists per second. Recommendations should reflect what each shopper has viewed and bought, refresh at least daily, and adapt within minutes to what they are browsing right now. The row must never delay the page: if recommendations are slow or broken, the page shows popular items instead.

Functional requirements

  • Return a ranked list of 20 products for a user and context (home page or a product page)
  • Exclude products the user already bought or that are out of stock
  • Collect views, clicks and purchases as training signals
  • Retrain models at least daily and roll out new models safely

Non-functional requirements

  • Responses in under 120 ms at p95
  • Fall back to popular items within the time budget when personalised results are unavailable
  • A shopper's recent clicks influence results within 5 minutes
  • New models can be compared with A/B tests before full rollout

Constraints and scale

  • 30 million daily active users, 12,000 recommendation requests per second at peak
  • 5 million products in the catalogue
  • About 2 billion interaction events a day

You will practise

  • Split work into offline training, precomputed candidates and fast online serving
  • Use a feature store and cache to keep online inference within a latency budget
  • Design graceful degradation for a non-critical page component
Show 2 hints
  1. Scoring 5 million products per request is impossible in 120 ms. What could be computed ahead of time?
  2. Which part of the answer changes every minute, and which part changes once a day?

Ready to build?

Open the canvas, place your components and explain your decisions. Your draft saves automatically.

Sign in to start

Failure scenarios

  • A new model recommends nonsenseA newly trained model is rolled out to all users. Because of a bug in a feature pipeline, it recommends the same three phone cases to everyone, and click-through drops by 60% within an hour.

Run them from the workspace once your design is in place.