使用cassandra并保持数据一致性
众所周知,我们在cassandra中有ConsistencyLevel的ReplicationFactor。我们只是想利用它来保持数据一致性。因为它应该保留价格信息。
那么哪种策略更好呢?
写全部 确保在响应客户端之前写入已写入所有 N 个副本。 操作失败
任何无响应的副本都会使读取全部 将查询所有副本,并在所有副本回复后返回具有最新时间戳的记录。任何无响应的副本都会导致操作失败。
看来 write ALL 肯定是最安全的。 但不确定阅读全部是否更好?关于它的优点和缺点有什么看法吗?您认为还有其他更好的 nosql 选择吗?
As we all know, we have ConsistencyLevel of ReplicationFactor in cassandra. And we just want to leverge it for keeping data consistency. Because it is supposed to keep the price info.
So which strategy is better?
Write ALL
Ensure that the write is written to all N replicas before responding to the client. Any unresponsive replicas will fail the operation
Read ALL
Will query all replicas and return the record with the most recent timestamp once all replicas have replied. Any unresponsive replicas will fail the operation.
It seems write ALL is for sure the safest.
But not sure if Read all is better? Any opinion about it of the pros and cons? Any other choice of nosql you think is better?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“更好”取决于您想要实现的目标。在一致性级别 ALL 上使用写入或读取意味着,即使一个节点无响应,您的集群也将无法进行写入(或读取)。
一般来说,在一致性级别 QUORUM 上写入和读取是一种有效的平衡方法,因为它提供完全一致性(您永远不会读取过时的值),但也可以容忍少数节点的故障。
但“最佳”方法取决于您的应用程序以及您实际需要的一致性。特别是,如果您可以容忍较低的一致性,则可以获得更好的读写性能(以及更好的可用性)。
"Better" depends on what you are trying to achieve. Using write or read at consistency level ALL means that your cluster will be unavailable for write (or read) if even one node is unresponsive.
Generally, writing and reading both at consistency level QUORUM is an effective balanced approach since it provides full consistency (you will never read an out-of-date value) but can also tolerate the failure of a minority of nodes.
But the "best" approach depends on your application and how much consistency you actually need. In particular, you can get better read and write performance (and better availability) if you can tolerate lower consistency.