TikTok
Short-Form Video Platform
Design a short-video app where people upload clips and scroll an endless, personalized feed chosen by a recommendation system rather than by whom they follow.
Overview
In this app, people record short videos and everyone else scrolls through them one at a time. The main screen, the For You feed, is not built from accounts you follow. A recommendation system picks each video from the whole catalog based on what you have watched, finished, replayed, liked or skipped. Following still exists, but it is a second tab.
That changes the design compared with a follow-based feed such as Twitter. There is no fan-out of posts to followers. Instead there are three heavy systems: a video pipeline that turns every upload into several playable versions, a delivery system that starts a video instantly on any network, and a recommendation system that ranks millions of videos for each viewer and updates itself from their behavior within minutes.
Questions to ask first
Pin down the scope before designing. These are the questions worth asking, each with the answer this design assumes.
- How many users and views? 100 million daily users watching about 100 videos each: 10 billion views a day.
- How many uploads, and how long? 5 million a day, 30 seconds on average.
- Which part should we go deep on? The For You feed first, then upload and playback.
- How fast must a video start? Under about 300 ms after the swipe. That is a target we chose.
- How fresh must recommendations be? They should react to this session's behavior within seconds or minutes.
- Must videos be checked before they are shown? Yes. Automated checks run before a video can be recommended.
The design at a glance
The phone app talks to an API gateway. Uploads go through the upload service, which hands out signed URLs so the video goes straight to object storage, and a job queue feeds the workers that transcode it. For the feed, the gateway calls the feed service, which asks the recommender which video IDs to show; the app then plays them from CDN edges that fetch from object storage, while every watch event flows through the event stream to online training. The Visual Explanation below draws it.
What you will be able to do
- Size the video pipeline, storage and delivery bandwidth from views and uploads.
- Design the upload pipeline so every step can be retried safely.
- Explain adaptive bitrate playback and why the next videos are prefetched.
- Walk through the recommendation funnel: candidates, ranking, re-ranking.
- Describe how watch events reach the model within minutes, and how new users and new videos get a fair start.
Key concepts
- Interest graph
- Candidate generation
- Ranking
- Watch-time signals
- Online training
- Embeddings
- Cold start
- Transcoding
- Adaptive bitrate
- CDN prefetch
Functional requirements
- Upload a short video with a caption and a sound; it becomes watchable once processed and checked
- Scroll a personalized For You feed, one video at a time, without an end
- Scroll a Following feed of recent videos from followed accounts
- Like, comment, share, follow; show counts on each video
- Record what each viewer watched, for how long, and what they skipped
Non-functional requirements
- A video starts playing within about 300 ms of the swipe (a target we chose)
- A feed page of 10 videos is chosen within about 150 ms at p99 (a target we chose)
- Watch behavior changes recommendations within minutes
- Playback and the feed stay up when the recommender is degraded: fall back to simpler candidates
- No video is recommended before it passes automated checks
Interview questions
- How does the For You feed choose videos?
- How does the feed react to what I just watched?
- How do you make a video start instantly on swipe?
- Walk through an upload.
- How do new videos get a chance?
- How do you count likes and views on a viral video?
- What happens if the recommender goes down?
Sign up free to read the full topic
More System Design topics
Start free on Cariara · Coding problems · System design studio