Design a ranking and recommendation system
MetaSoftware Engineer · Technical ScreenLast updated
This problem tests your ability to design a multi-stage recommendation pipeline that balances low-latency retrieval with high-precision ranking at scale.
Scenario
Design a personalized content feed system (e.g., similar to Facebook News Feed or Instagram Explore) that recommends items to users in real-time. The system must serve 100 million daily active users with low latency and handle a massive volume of content updates.
Requirements
Functional Requirements
- Provide a personalized list of content items for a user.
- Support real-time updates: new posts should be eligible for recommendation shortly after being published.
- Provide an API endpoint
get_feed(user_id, count).
Non-Functional Requirements
- Latency: The system should return recommendations in under 200ms.
- Scale: Support high read and write throughput.
- Freshness: Minimize the time-to-feed for newly created content.
Evaluation Criteria
- Candidate Generation: How do you narrow down millions of items to a few hundred candidates?
- Ranking: How do you score these candidates for a specific user?
- System Architecture: How do the components (Retrieval, Ranking, Feature Store) interact?
- Feedback Loops: How do you incorporate user interaction data (clicks, likes, skips) to improve the model?
Constraints
- Assume you have an existing ML model service that can score a candidate list, but it is too slow to run on the entire corpus.
- The system must handle cold starts for both new users and new content.
Hints
Hint 1
Consider a funnel approach: use fast, lightweight retrieval methods to filter the corpus, followed by a heavier, more accurate machine learning model to rank the results.
Hint 2
Think about how to balance 'exploitation' (showing content similar to what the user likes) with 'exploration' (showing new, potentially interesting content to avoid filter bubbles).
Hint 3
Identify where caching can be applied, noting the trade-offs between serving pre-computed feed results and calculating them on the fly.
Follow-up questions
- How would you handle a 'flash crowd' event where a specific piece of content suddenly goes viral and requires massive scaling?
- How would you measure the performance of your system using offline metrics (like AUC or NDCG) vs. online metrics (like CTR or dwell time)?
- How does your design change if you need to enforce strict diversity requirements, such as ensuring content from different categories is displayed?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.