Design a Recommendation System - ML System Design
Complete ML system design walkthrough: from problem framing to production deployment.
For ML systems, focus on data availability, business objectives, and model constraints.
What type of recommendations are we building? (products, content, ads, etc.)
E-commerce product recommendations, similar to Amazon's 'Customers who bought X also bought Y' and personalized homepage.
What's the scale? Number of users and items?
50 million active users, 100 million products, 1 billion interactions per day.
What user interactions do we have access to?
Views, clicks, add-to-cart, purchases, ratings (1-5 stars), search queries, time spent on page.
What's the business objective we're optimizing for?
Primary: Increase conversion rate (purchases). Secondary: Increase average order value and user engagement.
Real-time or batch recommendations?
Both. Real-time for homepage when user logs in, batch for email campaigns.
How fresh do recommendations need to be?
Should reflect inventory changes within 1 hour, user behavior within 5 minutes.
Any constraints on recommendation diversity or fairness?
Yes, avoid filter bubbles, ensure category diversity, and give new products a chance.
What's the latency requirement for serving?
P99 < 100ms for API calls, including all personalization logic.
Interview Practice Questions
Practice these open-ended questions to prepare for system design interviews. Think through each scenario and discuss trade-offs.
Multi-Stage Recommendation Pipeline: Design a two-stage recommendation system (candidate generation + ranking) for 100M+ users with sub-100ms latency. Address model architecture, feature engineering, candidate selection strategies, and real-time personalization while maintaining recommendation quality.
Cold Start & Exploration: Build a system handling new users and items effectively while balancing exploration vs exploitation. Design content-based bootstrapping, demographic targeting, bandits for exploration, and transition strategies as interaction data accumulates.
Real-Time Feature Pipeline: Implement a feature engineering system processing 1B+ daily interactions for recommendation models. Address streaming data processing, feature stores, embedding updates, and handling concept drift with minimal serving latency impact.
Diversity & Fairness: Design recommendation systems that balance relevance with diversity and fairness. Address filter bubble prevention, demographic bias mitigation, content creator fairness, and multi-stakeholder optimization while maintaining user engagement.
A/B Testing & Evaluation: Build comprehensive experimentation infrastructure for recommendation systems. Design multi-armed bandits, long-term impact measurement, cross-experiment interference handling, and metrics that capture both engagement and user satisfaction.
Content Understanding & Embeddings: Design a content understanding system that creates rich item representations from multimodal content (text, images, video, audio). Address embedding generation, similarity search at scale, content freshness, and integration with collaborative signals.
🎯 ML System Design Interview Tips
- ✅ Frame the business problem as ML objective
- ✅ Discuss data quality and availability
- ✅ Compare multiple model architectures
- ✅ Address training-serving skew
- ✅ Plan for model monitoring and retraining
- ✅ Consider fairness and bias
- ❌ Jumping to complex models too quickly
- ❌ Ignoring data pipeline complexity
- ❌ Forgetting about feature engineering
- ❌ Not discussing offline vs online metrics
- ❌ Overlooking model versioning
- ❌ Missing production challenges