本文介绍了亚马逊-DynamoDB一致性强的读物,它们是最新的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在试图将Dynamodb用于其中一个项目时,我对dynamodb的强一致性模型有疑问。从常见问题解答中

根据上面的定义,我得到的是,强一致性读取将返回最新的写入值。



以示例为例:假设Client1在密钥K1上发出了一个写入命令以从V0更新值到V1几毫秒后,Client2发出密钥K1的读取命令,则在始终保持强一致性的情况下,始终会返回V1,但是在最终保持一致性的情况下,可能会返回V1或V0。我的理解正确吗?



如果是,如果写操作返回成功但数据未更新到所有副本并且我们发出强一致性读取该怎么办,它将如何确保返回



以下链接


In an attempt to use Dynamodb for one of projects, I have a doubt regarding the strong consistency model of dynamodb. From the FAQs

From the definition above, what I get is that a strong consistent read will return the latest write value.

Taking an example: Lets say Client1 issues a write command on Key K1 to update the value from V0 to V1. After few milliseconds Client2 issues a read command for Key K1, then in case of strong consistency V1 will be returned always, however in case of eventual consistency V1 or V0 may be returned. Is my understanding correct?

If it is, What if the write operation returned success but the data is not updated to all replicas and we issue a strongly consistent read, how it will ensure to return the latest write value in this case?

The following linkAWS DynamoDB read after write consistency - how does it work theoretically? tries to explain the architecture behind this, but don't know if this is how it actually works? The next question that comes to my mind after going through this link is: Is DynamoDb based on Single Master, multiple slave architecture, where writes and strong consistent reads are through master replica and normal reads are through others.

解决方案

Short answer: Writing successfully in strongly consistent mode requires that your write succeed on a majority of servers that can contain the record, therefore any future consistent reads will always see the same data, because a consistent read must read a majority of the servers that can contain the desired record. If you do not perform a strongly consistent read, the system will ask a random server for the record, and it is possible that the data will not be up-to-date.

Imagine three servers. Server 1, server 2 and server 3. To write a strongly consistent record, you pick two servers at minimum, and write the data. Let's pick 1 and 2.

Now you want to read the data consistently. Pick a majority of servers. Let's say we picked 2 and 3.

Server 2 has the new data, and this is what the system returns.

Eventually consistent reads could come from server 1, 2, or 3. This means if server 3 is chosen by random, your new write will not appear yet, until replication occurs.

If a single server fails, your data is still safe, but if two out of three servers fail your new write may be lost until the offline servers are restored.

More explanation:DynamoDB (assuming it is similar to the database described in the Dynamo paper that Amazon released) uses a ring topology, where data is spread to many servers. Strong consistency is guaranteed because you directly query all relevant servers and get the current data from them. There is no master in the ring, there are no slaves in the ring. A given record will map to a number of identical hosts in the ring, and all of those servers will contain that record. There is no slave that could lag behind, and there is no master that can fail.

Feel free to read any of the many papers on the topic. A similar database called Apache Cassandra is available which also uses ring replication.

http://www.read.seas.harvard.edu/~kohler/class/cs239-w08/decandia07dynamo.pdf

这篇关于亚马逊-DynamoDB一致性强的读物,它们是最新的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 05:39