mongodb 在 CAP 定理中处于什么位置? [英] Where does mongodb stand in the CAP theorem?

查看:44
本文介绍了mongodb 在 CAP 定理中处于什么位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论我看哪里,我都看到 MongoDB 是 CP.但是当我深入研究时,我发现它最终是一致的.使用safe=true时是CP吗?如果是这样,那是否意味着当我使用safe=true写入时,所有副本都会在得到结果之前被更新?

Everywhere I look, I see that MongoDB is CP. But when I dig in I see it is eventually consistent. Is it CP when you use safe=true? If so, does that mean that when I write with safe=true, all replicas will be updated before getting the result?

推荐答案

MongoDB 默认是强一致性的——如果你先写然后读,假设写成功,你将始终能够读取结果你刚读的写.这是因为 MongoDB 是单主系统,默认情况下所有读取都转到主系统.如果您有选择地启用从辅助节点读取,那么 MongoDB 最终会变得一致,从而可以读取过时的结果.

MongoDB is strongly consistent by default - if you do a write and then do a read, assuming the write was successful you will always be able to read the result of the write you just read. This is because MongoDB is a single-master system and all reads go to the primary by default. If you optionally enable reading from the secondaries then MongoDB becomes eventually consistent where it's possible to read out-of-date results.

MongoDB 还通过副本集中的自动故障转移获得高可用性:http://www.mongodb.org/display/DOCS/Replica+Sets

MongoDB also gets high-availability through automatic failover in replica sets: http://www.mongodb.org/display/DOCS/Replica+Sets

这篇关于mongodb 在 CAP 定理中处于什么位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆