Amazon - DynamoDB Strong consistent reads, Are they latest and how?

前端 未结 3 1842
轻奢々
轻奢々 2020-12-24 11:57

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

Strongly Consisten

3条回答
  •  死守一世寂寞
    2020-12-24 12:31

    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

提交回复
热议问题