简体   繁体   中英

Any Idea/guess of how twitter saves its tweets in the database and updates it real-time

I am making a twitter type of website (not as big as twitter:), but without using any twitter api), I have to decide what kind of database I should use and how to maintain it in consistent state.

The main problem: Suppose my website is a twitter clone(that will make my question easier to understand), if I have a user "A" has 100 friends and all his friends tweet something as the same time "A" logs in so at that point in time tweets will be fetched from database, but the database is being updated by his friends tweets => database is in inconsistent state

Q1> What would be the best solution to it? maintain 2 database, use multi-threading etc? Can anyone explain in detail.

Q2>What will be the best database for this particular usage.

when somebody writes in db table - the whole table itself is not locked, so others can write there concurrently. And read it. So user A will receive all that others had time to wrote (if their transactions committed successfully). So there I don't see here any inconsistency

Twitter uses a noSQL database called cassandra.
Take a closer look here: Apache Cassandra

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM