If you were to create an application like twitter, how would you go about designing the messaging system?
Specifically look for ideas on the basic data model, and how you would write the method that takes the user's tweet and then sends it out to all its followers?
example:
Tweets ( tweetID, userID, message, datesend)
User (userID, ...)
Followers(userID, followerUserID)
Inbox(userID, tweetID)
is the above model a good starting point?
Would you first insert the tweet, then push a message to the queue. Then one-by-one, take a message off the queue and push the message to its subscribers?
(I am ignoring the mobile functionality of twitter, just focussing on the web based functionality, but I thought of using a queue from the start so one could add other functionality later)
Twitter handles thousands of tweets per second so you can't have just one big system or table to handle all the data so it should be handled through a distributed approach. Twitter uses the strategy scatter and gather where it set up the multiple servers or data center which allow indexing.
Architecture of Twitter database server [16]. For storage purpose, Twitter uses MySQL and Cassandra that are accessed by various services through Thrift where the FlockDB storage solution built on top of MySQL was used to store relationships between users and followers/friends.
The High Scalability blog has a number of articles on twitter and it's infrastructure and changes over time that might interest you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With