Design Twitter

Problem Statement:


Step-1: What is Twitter ?


Step-2: Requirements and Goals of the System


Step-3: Capacity Estimation and Constraints

How many favorites per day ?
How many total tweet-views our system will generate ?
Storage Estimates:
Bandwidth Estimates


Step-4: System APIs

Once we’ve finalized the requirements, it’s always a good idea to define the system APIs. This would explicitly state what is expected from the system.

Tweet API
tweet(api_dev_key, tweet_data, tweet_location, user_location, media_ids, maximum_results_to_return)


Step-5: High Level System Design


Step-6: Database Schema


Step-7: Data Sharding


a) Sharding based on UserID:


b) Sharding based on TweetID:


c) Sharding based on Tweet Creation Time:


d) Sharding based on TweedID and Tweet Creation Time


Step-8: Cache

Which cache replacement policy would best fit our needs ?
How can we have more intelligent cache ?
What if we cache the latest data ?

Step-9: Timeline Generation


Step-10: Replication and Fault Tolerance


Step-11: Load Balancing


Step-12: Monitoring


Step-13: Extended Requirements

How to serve feeds ?
Retweet:
Who to follow ? How to give suggestions ?
Moments:




← Previous: Design Facebook Messenger

Next: Design Youtube / Netflix →