Katkat

Design a recommendation system

SalesforceSoftware Engineer · Technical Screen

Last updated

This problem tests the ability to design an end-to-end recommendation engine, focusing on the pipeline from data ingestion to real-time inference and model evaluation.

Scenario: Personalized Product Recommendations

You are asked to design a personalized product recommendation system for an e-commerce platform that hosts over 10 million products and serves 1 million daily active users. The goal is to surface relevant products on the user's 'Recommended for You' homepage section.

Functional Requirements

  • Provide a list of personalized product recommendations for a logged-in user.
  • Ensure the system can handle high read traffic (10k requests per second).
  • Maintain low latency (sub-200ms) for the personalized feed.

Non-Functional Requirements

  • System must be resilient to cold-start problems for new products.
  • The architecture should support A/B testing different recommendation algorithms.

Deliverables

  1. High-level architecture: Describe the components from data collection to inference.
  2. Data Model & Features: Define the necessary data structures and the types of features used (e.g., user embeddings, item metadata).
  3. Candidate Generation vs. Ranking: Explain how you would balance performance and precision.
  4. Evaluation: Propose metrics to measure success offline (model training) and online (user behavior).

Considerations

  • How will you handle users with no historical data (cold start)?
  • What infrastructure is needed to update user profiles in near real-time?

Hints

Hint 1

Consider a two-stage architecture: a fast candidate generation phase (retrieval) followed by a compute-heavy ranking phase.

Hint 2

Think about how to transform raw user event logs (clicks, views, purchases) into feature vectors stored in a low-latency database.

Hint 3

To solve the cold-start problem, consider incorporating content-based filtering (using product metadata) alongside collaborative filtering.

Follow-up questions

  • How would you re-rank or filter the results to ensure diversity, so the user doesn't see 10 identical products?
  • How does your design change if the latency requirement drops to sub-50ms?
  • How would you handle 'data drift' where user preferences change drastically over time?