Design a real-time home feed ranker
PinterestMachine Learning Engineer · OnsiteLast updated
This problem evaluates your ability to design a multi-stage recommendation architecture capable of integrating real-time user signals, managing feature latency, and balancing ranking accuracy with system throughput.
Scenario
You are tasked with designing a real-time home feed ranking system for a visual discovery platform. Users expect a personalized stream of content that updates based on their immediate interactions (e.g., clicks, saves, or hides). The system must serve millions of daily active users with sub-200ms latency.
Requirements
- Functional: Build a pipeline that retrieves candidate items and ranks them using a machine learning model, incorporating both static user/content features and recent streaming engagement signals.
- Non-functional: The system must handle high request volumes, maintain low latency, and support model updates without significant downtime.
Your Task
Please design the architecture for this service. Your response should cover:
- System Architecture: High-level components (Candidate Retrieval, Ranking, Feature Store).
- Feature Pipeline: How do you handle "eventual consistency" vs. "real-time" features? How do you update user profiles based on a user's action in the last 10 seconds?
- Modeling Strategy: How do you manage the trade-off between model complexity (e.g., Deep Learning models) and latency? Do you use a multi-stage ranking approach?
- Operationalizing: How do you monitor for "filter bubbles" or model drift? How would you handle a sudden spike in traffic or a failed model deployment?
Hints
Hint 1
Consider a two-stage architecture: a high-recall candidate generation layer (e.g., vector search) followed by a high-precision ranking layer.
Hint 2
Use a Lambda architecture or a dual-store approach (a low-latency Key-Value store for real-time features and a Data Warehouse for batch features) to serve model inputs.
Hint 3
Think about how to handle the 'cold start' problem for new content items or users using real-time exploration strategies.
Follow-up questions
- How would you specifically handle the engineering challenge of 'feature staleness'—where the features used in training significantly differ from those available during real-time inference?
- If we wanted to introduce a 'diversity' constraint to ensure the feed isn't just one type of content, where in the architecture would you implement that and why?
- How would you design a testing framework to perform A/B testing on a new model version without negatively impacting the production feed experience for 100% of users?
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.