Skip to main content

Design TikTok

Premium

Watch Adam Schneider, Google TPM, answer the system design question "Design TikTok."

To submit your own answer for this question and get feedback, visit the answer in our interview question database.

Key Concepts

Reliable and Resilient Infrastructure: TikTok's system must be able to handle a large number of users and always be available.

Load Balancing: TikTok must be able to handle a significant increase in traffic. A load balancer can help distribute traffic and ensure that the system is able to handle the load.

Choosing a Database: TikTok will need to store and link structured user data objects. Choosing the right database is important to ensure that the system can handle the load and respond quickly.

Consider the Scale of the System

To store compressed video files and user metadata, you need a system that is always available, responds quickly, and can grow to support more users. TikTok has one million users who use it every day, so the system must be able to handle that many people.

API and Database Schema Design

An API can be designed with endpoints such as "Upload Video" and "Get User Activity".

A relational database system, such as PostgreSQL, can be used to store and link structured user data objects.

To reduce the load on the database and improve latency, preloading a cache of the top ten videos for each user can be implemented.

Video UUID and ID Field

To associate user activity, such as liking and following videos, with specific videos, a video UUID and ID field is required.

User activity can be stored in a database, and an API endpoint can be developed for a GET request to return a list of the user's likes and followers.

Content Delivery Network and Load Balancer

To handle a 10x increase in traffic, a Content Delivery Network (CDN) can be used to cache and route video content traffic to the closest node.

A load balancer can also be used for scaling deployments and performing zero downtime deployments.

Regional Database Sharding and Pre-Caching Service

A regional database sharding service can facilitate the distribution of load between databases and a read-only worker.

A pre-caching service can be implemented to manage GET requests and preloading video content