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

查看:217
本文介绍了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中的所有想法,但事实并非如此,将两者分开牢牢记住很重要。原始的Dynamo系统由Amazon在 Dynamo Paper 中仔细描述。考虑这些问题时,如果您熟悉基于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空间中的放置位置。根据Amazon的说法,DynamoDB维护每个项目的多个副本以确保持久性。当您收到对写入请求的操作成功响应时,DynamoDB确保该写入在多个服务器上是持久的。但是,更新传播需要时间。所有副本。 (数据读取和一致性注意事项)。此外,DynamoDB不需要应用程序像Dynamo那样进行冲突解决。假设他们希望提供尽可能多的可用性,因为他们说它们正在写入多个服务器,因此DyanmoDB中的写入等效于Cassandra QUORUM 级别。而且,DynamoDB似乎不支持提示的切换,因为这可能导致需要解决冲突的情况。为了获得最大的可用性,不一致的读取只需达到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.

总而言之,我得出以下结论:

In summary, I conclude that:


  • 写入是法定人数,因此该行的大多数节点被复制到必须为成功写入可用

  • 不一致的读取为一个,因此仅需要一个具有该行的节点,但返回的数据可能已过期

  • 一致的读取是法定人数,因此复制行的大多数节点必须是可用的,读取才能成功

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

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天全站免登陆