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.
我正在制作一个Twitter类型的网站(不像twitter那么大:),但没有使用任何Twitter api),我必须决定我应该使用什么样的数据库以及如何将其保持在一致的状态。
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
主要问题:假设我的网站是一个推特克隆(这将使我的问题更容易理解),如果我有一个用户“A”有100个朋友和他的所有朋友推特的东西同时“A”登录所以在那个时间点的推文将从数据库中获取,但数据库正由他的朋友推文更新=>数据库处于不一致的状态
Q1> What would be the best solution to it? maintain 2 database, use multi-threading etc? Can anyone explain in detail.
Q1>什么是最好的解决方案?维护2个数据库,使用多线程等?任何人都可以详细解释。
Q2>What will be the best database for this particular usage.
Q2>这个特定用途的最佳数据库是什么。
2 个解决方案
#1
0
Twitter uses a noSQL database called cassandra.
Take a closer look here: Apache Cassandra
Twitter使用名为cassandra的noSQL数据库。仔细看看这里:Apache Cassandra
#2
0
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
当有人在db表中写入时 - 整个表本身没有被锁定,所以其他人可以同时写入。并阅读它。因此,用户A将收到其他人有时间写的所有内容(如果他们的交易成功提交)。所以在这里我没有看到任何不一致
#1
0
Twitter uses a noSQL database called cassandra.
Take a closer look here: Apache Cassandra
Twitter使用名为cassandra的noSQL数据库。仔细看看这里:Apache Cassandra
#2
0
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
当有人在db表中写入时 - 整个表本身没有被锁定,所以其他人可以同时写入。并阅读它。因此,用户A将收到其他人有时间写的所有内容(如果他们的交易成功提交)。所以在这里我没有看到任何不一致