Overview

Twitter is a free microblogging social network with 397 million users as of 2021. One of the main reasons for Twitter’s popularity is the vast sharing of breaking news on the platform.

In this lesson, we will describe the functional and non-functional requirements of Twitter. Then we’ll look deeper into its API design and identify the different components of the Twitter architecture. In addition, we will discuss how to manage the Top K problem, such as Tweets liked or viewed by millions of users on Twitter. Finally, we’ll also explain how Twitter performs load balancing for its microservices system to manage billions of requests between the various service instances.

Requirements

Let’s go over the functional and non-functional requirements below.

Functional requirements

  • Registered users can post and delete one or more Tweets on Twitter.

  • They can like, dislike, and reply to Tweets.

  • Users can search tweets by using keywords, hashtags, or usernames.

  • Users can follow or unfollow other users.

  • Users can view other users’ timelines with their Tweets or their own home timelines with the Tweets of users they follow.

Non-functional requirements

  • Availability: Twitter’s service needs to be highly available.

  • Latency: The latency of the distribution of Tweets to followers must be low.

  • Scalability: Twitter’s workload is read-heavy with around a 1:1000 read-to-write ratio. So high storage capacity is needed to store and deliver Tweets posted by public figures to their millions of followers.

  • Reliability: Twitter needs to be highly reliable, and no uploaded content should get deleted or damaged.

  • Consistency: An effective technique is needed to offer rapid feedback to the user (who liked someone’s post), then to other specified users in the same region, and finally to all worldwide users linked to the Tweet.

Building blocks we will use

We will use the following building blocks in the Twitter design.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.