Design a recommendation system (Netflix, YouTube, TikTok feed)

    A two-stage pipeline that goes from millions of candidate items down to a personalized, ranked feed of ~20-50 items in under 200ms — the architecture behind Netflix, YouTube, and TikTok's feed.

    AI & Machine Learning, 8 components, about 35 min

    The full guide covers requirements, estimates, the API, the data model, deep dives, trade-offs, failure modes and the follow-up questions interviewers ask.

    Read the full guide on Substack

    Key points

    • Candidate generation: collaborative filtering or a two-tower embedding model retrieves ~500 candidates from millions of items in milliseconds.
    • Ranking: a heavier model (gradient-boosted trees or a deep model) scores those ~500 candidates using rich features unavailable at retrieval time.
    • Feature store serves both offline (training) and online (serving) features — point-in-time correctness matters, or you leak future data into training.
    • Business-rule re-ranking after the model: diversity, freshness, dedup against recently-shown items.
    • Feedback loop: impressions/clicks/watch-time stream back in to retrain both stages — but naive retraining amplifies existing popularity bias.

    Sign in to track this guide in your curriculum progress.