Twitter System Design

  • HomeTimeline is the one, where user sees his/her friend’s tweets.
  • UserTimeline is the one, where user sees his/her own tweets.
  • User Table → Stores user information.
  • Tweet Table → Stores the tweets information.
  • Follower Table → Stores the mapping between the users.
  • <UserId, List_of_Tweets> → To be used for User Timeline.
  • <UserId, List_of_Followers> → To be used for Home Timeline.
  • Say User U1 have 100 friends/followers.
  • Now, when user U1 tweets, then first and foremost the pre-computed UserTimeline is updated in Redis.
  • Secondly all the 100 friend’s HomeTimeline is also updated. It means that, we store the pre-computed HomeTimeline into the Redis.
  • Whenever any one of 100 friend, opens their respective HomeTimeline, the same is fetched from the Redis and shown.
  • A Celebrity may have Millions of followers.
  • Whenever celebrity tweets, it’s not advisable to update the HomeTimeline of all those Million followers.
  • In this case, mix & merge approach is adopted.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
aditya goel

aditya goel

Software Engineer for Big Data distributed systems