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

  • How many users and views? — 100 million daily users, about 100 videos each: 10 billion views a day
  • How many uploads, 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 (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 before a video can be recommended

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