Social & content · Advanced
TikTok-style recommendation feed
Retrieval → ranking funnel with a feature store and a model that retrains on live watch events.
Every part, and why it is there
TikTok app
Shows one full-screen video at a time. Every swipe, replay and watch duration is a signal, so the client reports far more events than requests it makes.
Video CDN
The app prefetches the next few videos while the current one plays, from edge caches. That is why a swipe starts the next video instantly.
Video storage
Transcoded short videos in several bitrates. The CDN pulls from here on a miss.
API gateway
Routes feed requests to the feed service and the firehose of interaction events to the event collector.
For You service
Assembles the next batch of ~10 videos: ask retrieval for a few thousand candidates, ask the ranker to score them, then filter what the user has already seen and mix in some fresh content.
Candidate retrieval
Cheaply narrows hundreds of millions of videos to a few thousand plausible ones: similar to what you watched, popular nearby, from creators you like. It must be fast because it is not very precise.
Embedding index (ANN)
Users and videos are mapped to vectors; “nearest neighbours” of your vector are videos you will probably like. Approximate search trades a little accuracy for millisecond answers.
Ranking model
A large model that predicts, for each candidate, how long you will watch and whether you will like, share or skip it. It is expensive, so it only sees the few thousand candidates retrieval passed on.
Feature store
Precomputed facts the ranker needs in milliseconds: a video’s recent completion rate, a user’s favourite topics. Keeping them in a key-value store avoids recomputing them per request.
Model parameters
The ranker’s embedding tables and weights. Training writes updated parameters here continuously and serving picks them up within minutes.
Event collector
Accepts batches of watch and swipe events and appends them to the stream. It does no work beyond validation so the client never waits on it.
Interaction stream
Every impression and its outcome, readable by several consumers. Joining “what we showed” with “what the user did” here is what produces training examples.
Online training
Trains the ranking model on fresh interactions and pushes new parameters, plus updates fast-moving features. Learning in minutes rather than daily is what lets the feed react to a new interest within one session.
Asked in interviews at
- meta
Learn more
- TikTok Monolith - Online Recommendation Systems | Distributed Systems Deep Dives With Ex-Google SWE (Jordan has no life)
- 22: Recommendation Engine (YouTube, TikTok) | Systems Design Interview Questions With Ex-Google SWE (Jordan has no life)
- Recommendation System Infra Basics 1 (Hello Interview)
- Monolith: Real Time Recommendation System With Collisionless Embedding Table (ByteDance (arXiv))
- System design for recommendations and search (Eugene Yan)
- Real-time machine learning for recommendations (Eugene Yan)