关于 Twitter 如何将其推文保存在数据库中并实时更新的任何想法/猜测
我正在制作一个 twitter 类型的网站(不像 twitter 那么大:),但不使用任何 twitter api),我必须决定我应该使用哪种数据库以及如何维护它处于一致状态。
主要问题:假设我的网站是 Twitter 克隆(这将使我的问题更容易理解),如果我有一个用户“A”有 100 个朋友,并且他的所有朋友都在“A”登录的同时发推文,那么该时间点的推文将从数据库中获取,但数据库正在由他的朋友推文更新 =>数据库处于不一致状态
Q1>最好的解决方案是什么?维护2个数据库,使用多线程等?谁能详细解释一下。
Q2>最适合这种特定用途的数据库是什么?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Twitter 使用名为 cassandra 的 noSQL 数据库。
仔细看看这里:Apache Cassandra
Twitter uses a noSQL database called cassandra.
Take a closer look here: Apache Cassandra
当有人在数据库表中写入时 - 整个表本身没有被锁定,因此其他人可以同时写入。并阅读它。因此,用户 A 将收到其他人有时间写入的所有内容(如果他们的事务提交成功)。所以我没有看到任何不一致之处
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