DynamoDB:条件写入与 CAP 定理 [英] DynamoDB: Conditional writes vs. the CAP theorem

查看:16
本文介绍了DynamoDB:条件写入与 CAP 定理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 DynamoDB,两个独立的客户端尝试同时写入同一个项目,使用条件写入,并尝试更改条件引用的值.显然,这些写入之一注定会因条件检查而失败;没关系.

Using DynamoDB, two independent clients trying to write to the same item at the same time, using conditional writes, and trying to change the value that the condition is referencing. Obviously, one of these writes is doomed to fail with the condition check; that's ok.

假设在写入操作期间,发生了一些不好的事情,并且一些不同的 DynamoDB 节点发生故障或失去彼此的连接.我的写操作会发生什么?

Suppose during the write operation, something bad happens, and some of the various DynamoDB nodes fail or lose connectivity to each other. What happens to my write operations?

它们会阻塞还是失败(牺牲 CAP 定理中的A")?他们会不会似乎都成功了,只是后来才发现其中一个实际上被忽略了(牺牲C")?或者它们是否会因为 DynamoDB 系统中发生的某种魔法(一致的哈希?)而以某种方式正常工作?

Will they both block or fail (sacrifice of "A" in the CAP theorem)? Will they both appear to succeed and only later it turns out that one of them actually was ignored (sacrifice of "C")? Or will they somehow both work correctly due to some magic (consistent hashing?) going on in the DynamoDB system?

这似乎是一个非常困难的问题,但我找不到任何讨论条件写入的可用性问题的可能性(例如,与一致性读取不同,其中可用性降低的可能性是明确的).

It just seems like a really hard problem, but I can't find anything discussing the possibility of availability issues with conditional writes (unlike with, for instance, consistent reads, where the possibility of availability reduction is explicit).

推荐答案

这方面缺乏明确的信息,但我们可以做出一些非常有力的推论.许多人认为 DynamoDB 实现了其前身Dynamo"的所有想法,但事实似乎并非如此,在您的脑海中将两者分开很重要.Amazon 在Dynamo 论文中仔细描述了最初的 Dynamo 系统.在考虑这些时,如果您熟悉基于 Dynamo 思想的分布式数据库,例如 Riak 和 Cassandra,也会很有帮助.特别是 Apache Cassandra,它提供了关于 CAP 的全方位权衡.

There is a lack of clear information in this area but we can make some pretty strong inferences. Many people assume that DynamoDB implements all of the ideas from its predecessor "Dynamo", but that doesn't seem to be the case and it is important to keep the two separated in your mind. The original Dynamo system was carefully described by Amazon in the Dynamo Paper. In thinking about these, it is also helpful if you are familiar with the distributed databases based on the Dynamo ideas, like Riak and Cassandra. In particular, Apache Cassandra which provides a full range of trade-offs with respect to CAP.

通过比较清楚分布的 DynamoDB 与 Cassandra 中可用的选项,我想我们可以看到它在 CAP 空间中的位置.根据亚马逊的说法,DynamoDB 维护每个项目的多个副本以确保持久性.当您收到对写入请求的操作成功"响应时,DynamoDB 确保写入在多个服务器上是持久的.但是,更新传播需要时间到所有副本."(数据读取和一致性注意事项).此外,DynamoDB 不需要应用程序像 Dynamo 那样进行冲突解决.假设他们想提供尽可能多的可用性,因为他们说他们正在写入多个服务器,所以在 DyanmoDB 中的写入相当于 Cassandra QUORUM 级别.此外,DynamoDB 似乎不支持 hinted handoff,因为这可能会导致需要解决冲突的情况.为了获得最大可用性,不一致的读取只需要相当于 Cassandras 的 ONE 级别.但是,要在给定仲裁写入的情况下获得一致的读取,需要 QUORUM 级别的读取(遵循 R + W > N 以保持一致性).有关 Cassandra 中级别的更多信息,请参阅关于 Cassandra 中的数据一致性.

By comparing DynamoDB which is clearly distributed to the options available in Cassandra I think we can see where it is placed in the CAP space. According to Amazon "DynamoDB maintains multiple copies of each item to ensure durability. When you receive an 'operation successful' response to your write request, DynamoDB ensures that the write is durable on multiple servers. However, it takes time for the update to propagate to all copies." (Data Read and Consistency Considerations). Also, DynamoDB does not require the application to do conflict resolution the way Dynamo does. Assuming they want to provide as much availability as possible, since they say they are writing to multiple servers, writes in DyanmoDB are equivalent to Cassandra QUORUM level. Also, it would seem DynamoDB does not support hinted handoff, because that can lead to situations requiring conflict resolution. For maximum availability, an inconsistent read would only have to be at the equivalent of Cassandras's ONE level. However, to get a consistent read given the quorum writes would require a QUORUM level read (following the R + W > N for consistency). For more information on levels in Cassandra see About Data Consistency in Cassandra.

总之,我的结论是:

  • 写入是法定人数",因此该行复制到的大多数节点必须可用于写入才能成功
  • Inconsistent Reads 为One",因此该行只需要一个节点可用,但返回的数据可能已过期
  • 一致读取是仲裁",因此该行复制到的大多数节点必须可用于读取成功

因此,写入与一致读取具有相同的可用性.

So writes have the same availability as a consistent read.

为了专门解决您关于两个同时条件写入的问题,一个或两个都将失败,具体取决于有多少节点关闭.但是,永远不会有不一致的地方.我认为写入的可用性与它们是否有条件无关.

To specifically address your question about two simultaneous conditional writes, one or both will fail depending on how many nodes are down. However, there will never be an inconsistency. The availability of the writes really has nothing to do with whether they are conditional or not I think.

这篇关于DynamoDB:条件写入与 CAP 定理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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