Search⌘ K
AI Features

System Design: Twitter

Explore the foundational aspects of the X (previously Twitter) platform, including its core features and scale. Define the structured approach used for this System Design case study, focusing on requirements, high-level architecture, and specialized client-side load balancing.

We'll cover the following...

Twitter

Twitter is a microblogging platform where users publish short posts referred to as tweets. Users engage with posts through likes, replies, and reposts. The platform serves hundreds of millions of monthly active users. The architecture must support rapid information propagation, especially during high-traffic events such as breaking news.

A user performs various operations on Twitter
A user performs various operations on Twitter

The illustration below shows Twitter’s user base by country as of January 2022 (source: Statista), with the US accounting for the largest segment. Geographic distribution statistics are vital for infrastructure design. They guide capacity planning and help us reduce latency by serving traffic from regions closer to users.

Country wise userbase on Twitter
Country wise userbase on Twitter

How will we design Twitter?

We will divide the design process into four sections:

  1. Requirements: Define the functional and non-functional requirements. We also estimate storage, bandwidth, and computational resource needs.

  2. Design: Cover the high-level design, API structure, and major architectural components. We also discuss managing the Top-k problem for viral content, such as tweets with millions of views.

  3. Client-side load balancers: Explain how Twitter balances billions of requests across its microservices. We analyze why Twitter uses a customized load-balancing approach rather than standard techniques.

  4. Quiz: Reinforce the core design concepts with a quiz.

Let’s begin by defining the requirements.