领导者/追随者比无主的好处
我正在学习有关复制策略的知识,并想知道Cassandra(无主)对Mongo(领导者/追随者)的优点。
从我阅读的内容来看,他们俩都写了同样的写作,因为在《无主》中写作的写作是通过法定人数发送给所有节点的,而在领导者/追随者中,主人最终将向所有关注者发送写信
以进行阅读,如果您使用的是无掌握的读物其中r + w> n,那么它也像领导者/追随者一样坚定不移,您只能从领导者那里阅读。
那么,您什么时候将领导者/追随者用无用的呢?它们如何通过阅读/写入方式不同?
我只有两个差异是:
- 领导者/追随者可能会从追随者那里读取比无掌握的读数更好,但是随后您牺牲了复制
- 滞后的一致性,因为我们不必担心当我们不必担心选举新主人时一个失败
I'm learning about replication strategies and wondering the pros of cassandra (masterless) over mongo (leader/follower).
From what I've read, they both scale writes the same because writes writes in masterless are sent to all nodes via a quorum, and in leader/follower the master will eventually send writes to all followers
For reads, if you are using a masterless where R + W > N, then it is also strongly consistent like leader/follower where you only read from the leader.
So when would you use leader/follower over masterless? How do they scale differently with reads/writes?
The only 2 differences I could find are:
- leader/follower may scale reads better than masterless if you read from followers, but then you sacrifice consistency from the replication lag
- Masterless has less downtime since we don't have to worry about electing new master when one fails
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
单身领导者的复制对于客户来说更简单。客户无需处理读取维修,在单个领导者复制系统中以支持酸性属性非常简单。
另外,通过单个领导者复制,您还有更多选择如何处理数据流 - 您可以同步,半同步或异步。所有这些都非常适合正确的用例。
对于一致性保证,CAP定理适用于两种情况,因此无法解决。
关于您的问题中陈述的一些评论:
无用的(dynamo样式更具体)的方式将写信发送给所有奴隶, ”发送到每个节点。但是,在w数量的节点确认写入后,将写入向客户确认。通过这种方法,一旦客户端获得写入确认,就可以理由如果客户在此之后开始读取,则可以看到数据。如果写入失败 - 少于w节点证实了写作,则未知客户会看到什么。周围有很多边缘案例。
至于领导者/追随者 - 写信最终仅以异步复制模式发送给关注者。您的系统也可以使用同步模式。在这种情况下,当所有复制品都获得更新时,将向客户端确认写作。因此,下一篇读取的每读都会看到最新数据。
当写入部分失败时,周围有许多边缘案例。通常,答案是读取维修 - 基本上说,如果一个客户读取部分保存的值(由小于w节点确认的写入) - 那么下一个下一个读取也会看到该值。但是正如我所说,这种特定的推理更加复杂。
Single leader replication is much simpler for clients to reason about. Clients don't need to deal with read repairs and it is much simple in a single leader replications system to support ACID properties.
Also, with a single leader replication you have more options how to handle data flows - you could go synchronous, semi-sync or async. All of these are really good for correct use cases.
As for consistency guarantees, CAP theorem is applicable to both cases, there is no way around that.
A few comments on statements in your question:
In masterless (dynamo style to be more specific) approach, writes are sent to every node. But the write is confirmed to a client after W number of nodes confirmed the write. With this approach, as soon as client got a write confirmation, it can reason that client will see the data if they have started the read right after. If the write fails - less than W nodes confirmed the write, then it is unknown what will clients see. And there are many edge cases around this.
As for leader/follower - writes are sent to followers eventually only in async replication mode. Your system could use sync mode as well. In this case, a write is confirmed to a client when all replicas got the update. Hence, every next read will see the latest data.
There are many edge cases around this when writes partially fail. Usually the answer is a read repair - which basically says if one client read a partially saved value (a write confirmed by less than W nodes) - then every next read will see that value as well. But as I said, this specific reasoning is a bit more complicated to reason about.