Practice/Meta/Design TikTok Video Recommendation System
Design TikTok Video Recommendation System
ML System DesignMust
Problem Statement
Design a personalized playlist generation system for a music streaming platform like Spotify that automatically creates custom playlists for users based on their listening history, preferences, and current context (time of day, activity, mood). The system should handle hundreds of millions of active users and generate fresh playlists daily while ensuring diverse music discovery alongside familiar favorites.
The key challenge is balancing personalization quality with computational efficiency at scale. Your system must process billions of listening events daily, analyze complex user-music relationships, and generate playlists within reasonable time frames. Additionally, the system needs to adapt to changing user preferences while maintaining engagement through serendipitous recommendations that expand users' musical horizons.
Key Requirements
Functional
- Playlist Generation -- Create personalized playlists of 30-50 songs based on user history, preferences, and contextual signals
- User Preference Learning -- Continuously learn from user interactions including plays, skips, likes, and playlist additions
- Music Feature Extraction -- Analyze audio characteristics, metadata, and collaborative signals to understand song attributes
- Diversity and Discovery -- Balance familiar content with new recommendations to maintain engagement and music discovery
- Contextual Awareness -- Incorporate time of day, user activity, and listening patterns into recommendations
Non-Functional
- Scalability -- Support 300M+ active users with billions of tracks; generate millions of playlists daily
- Reliability -- 99.9% uptime for playlist generation; graceful degradation when ML models are unavailable
- Latency -- Generate playlists within 2-3 seconds for on-demand requests; batch generation within 1 hour for daily updates
- Consistency -- Eventual consistency acceptable for user preference updates; strong consistency for user explicit actions
What Interviewers Focus On
Based on real interview experiences, these are the areas interviewers probe most deeply:
1. Machine Learning Pipeline Architecture
Understanding how to structure the ML workflow from data collection through model serving is critical. Interviewers assess whether you can design a scalable pipeline that handles both batch training and real-time inference.
Hints to consider:
- Separate feature engineering from model serving to enable independent scaling
- Consider a two-stage approach with candidate generation followed by ranking models
- Discuss offline training versus online learning tradeoffs and when each applies
- Plan for A/B testing infrastructure to evaluate model improvements safely
2. Feature Engineering at Scale
The quality of recommendations depends heavily on extracting meaningful signals from user behavior and music characteristics. Interviewers want to see thoughtful feature design that balances signal quality with computational cost.
Hints to consider:
- Combine collaborative filtering signals (user-user, song-song similarity) with content-based features
- Design time-decay functions for historical listening data to weigh recent behavior more heavily
- Extract contextual features like listening session patterns and skip rates
- Consider how to handle cold start problems for new users and newly released tracks
3. Real-Time vs Batch Processing Trade-offs
Deciding what to compute in real-time versus batch modes significantly impacts system performance and cost. Interviewers evaluate your ability to make pragmatic engineering decisions.
Hints to consider:
- Use batch processing for expensive operations like building user-song embeddings
- Reserve real-time processing for incorporating fresh user actions and contextual signals
- Design a hybrid caching strategy where pre-computed candidates are re-ranked in real-time
- Discuss how staleness affects recommendation quality and user experience
4. Data Storage and Retrieval Strategy
Efficiently storing and retrieving user profiles, song features, and model outputs at scale requires careful database selection and indexing strategies.
Hints to consider:
- Use vector databases or approximate nearest neighbor search for similarity computations
- Cache user profiles and frequently accessed song features in distributed memory stores
- Store raw listening events in a data lake for model training and analytics
- Consider graph databases for modeling complex user-artist-song relationships
5. Model Evaluation and Quality Metrics
Measuring recommendation quality goes beyond simple accuracy metrics. Interviewers look for understanding of business metrics and user satisfaction indicators.
Hints to consider:
- Track engagement metrics like completion rate, skip rate, and playlist save actions
- Measure diversity using intra-list distance and coverage of music genres
- Monitor for filter bubble effects and ensure serendipitous discovery
- Design feedback loops that connect business KPIs back to model improvements