500M daily active users
2 posts/user/day
20 feed requests*/user/day
5 likes/user/day
*feed request: opening the feed or scrolling through it
1B posts/day
100M have images (most have just 1 image)
~200M images/day
10B feed requests/per day
2.5B likes/day
new followers:
Total new followers/day: 99.9% * 500M * 15 + 0.1% * 500M * 5k = 8B + 2.5B = 10B
Total number of reads:
10B feed requests/day
100K/second
Total writes per day:
100M image posts/day => 1K/second
1B text posts => 10K/second
12B new followers/likes => 100K/second
Storage: ~20PB/month
Images:
5MB/image
1MB/low resolution alternative
100KB/very low resolution alternative
6MB/image
600TB/day
18PB/month
Followers, likes: just a few bytes, so the total is low
Text posts:
500B/post
still much lower than the storage needed for the images
POST /tweets
POST /follows
GET /feeds
POST /tweets/likes
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
We have several entities with several relationships between them, so we will go for a SQL DB.
(Note: images themselves will be stored in an S3 bucket; object storage is suitable because images are large, unstructured data)
Tables:
User: user_id, username, fullname
Tweet: tweet_id, poster_id (foreign key), text, timestamp
Image: image_id, s3_url, s3_url_low_res, s3_url_very_low_res, tweet_id (FK)
TweetToImage: tweet_id (FK), image_id (FK)
Follow: follower_id (FK), followee_id (FK)
Like: tweet_id (FK), liker_id (FK)
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
Explanations: