The system needs to be has high availability
The system needs to be scalable.
The consistency rule will be eventual consistency, especially for data like user likes.
I will assume there will be 100m DAU, each of them will spend 1hr in the app. And they will make 3 tweet per day, like 10 tweets per day.
Assume each twitter is 200 characters
QPS_tweets = 100k*1/3600/24 = 3k/s
QPS_like = 100k*10/3600/24 = 50k/s
Storage: Data Type of Twitters: text
images, videos will be send to Object storage,
External APIs:
POST postTweet(TweetDataType tweet, int userId)
POST shareTweet(TweetId tid, int userId)
POST countLikes(TweetId, int userId)
POST follow(int userId, int userIdToFollow)
Tweets Table:
tweetId, tweetContent, userId, creatorId
Tweets Like Table:
tweetId, likes
Tweets Table:
userId, followers
Main Services
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
HomePageConstruction Service -> followers: sort and find top K tweets and storage it into a database, send it back to followers
push vs pull
Push algorithm:
Pros:
Cons:
Pull algorithm
Pros:
Cons:
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?