Total users: 1M per day
Tweets sent per day: 5M => write QPS: 5M / 24 / 3600 = 58
Tweets view per day: 500M => read QPS: 500M / 24 / 3600 = 5800
Favorites per day: 50M => write QPS: 580
Total QPS: 6500
Peak QPS estimation: 2 * 6500 = 13000
This can be handled by 20s SQL machines
We can see read is much larger than write
Storage estimation:
One tweet = 200 byte text + 5M media
Assuming 20% of tweets contain media
One day: 5.2MByte * 1M + 200 byte * 4M = 5000 TB
If we store the data for 50 years: 50 * 365 * 5000 TB
Tweet table - Store tweet info
User table - Store user info
Like table - Store like info
Follow table - Store follow info
Timeline table - Store timeline info managed
Client
Media file CDN
Load balancer
API Gateway / Webapp server
Tweet service
Fanout service
Message queue - Kafka
Follow service
Favorite service
Home/profile service
Timeline Cache
Post tweet
View home/profile timeline
Follow / Unfollow
Like
Home/profile service
Timeline Cache
Sharding strategy
TweetId
Follow
Like
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?