最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - What guarantee does dynamoDB's strongly consistent read give? - Stack Overflow

programmeradmin4浏览0评论

I am aware that DynamoDB has a strongly consistent read option. See Consistency Model. It states:

A strongly consistent read in Amazon DynamoDB returns a result that reflects all writes that received a successful response prior to the read. To get a strongly consistent read result, you can specify optional parameters in a request.

Just to be pedantic, what does prior mean in this context? I have a few examples, with the second and third being more interesting than the first:

Example 1 (The boring one)

In the same program, same thread, one makes a successful write request X, then a later strongly consistent read Y in the same thread will see the result made by X or a write after X.

Example 2

I have two conditional write operations Wx, and Wy that I guarantee to be ordered with respect to each other. This is done by optimistic locking (i.e. a conditional update that checks a version on the item).

Now, let's assume Wx happens before Wy. Then, if in the same thread as Wy there is a strongly consistent read operation Rz following Wy, will it see the side effects of Wx?

Example 3

I listen to a DynamoDB stream via a Lambda (see this), which sees a PutItem record W on an item. If I then, in the handler, do a strongly consistent read to the item, will I be able to see the side-effect of W?

I am aware that DynamoDB has a strongly consistent read option. See Consistency Model. It states:

A strongly consistent read in Amazon DynamoDB returns a result that reflects all writes that received a successful response prior to the read. To get a strongly consistent read result, you can specify optional parameters in a request.

Just to be pedantic, what does prior mean in this context? I have a few examples, with the second and third being more interesting than the first:

Example 1 (The boring one)

In the same program, same thread, one makes a successful write request X, then a later strongly consistent read Y in the same thread will see the result made by X or a write after X.

Example 2

I have two conditional write operations Wx, and Wy that I guarantee to be ordered with respect to each other. This is done by optimistic locking (i.e. a conditional update that checks a version on the item).

Now, let's assume Wx happens before Wy. Then, if in the same thread as Wy there is a strongly consistent read operation Rz following Wy, will it see the side effects of Wx?

Example 3

I listen to a DynamoDB stream via a Lambda (see this), which sees a PutItem record W on an item. If I then, in the handler, do a strongly consistent read to the item, will I be able to see the side-effect of W?

Share Improve this question edited Mar 20 at 9:06 ph3rin asked Mar 20 at 9:04 ph3rinph3rin 4,8961 gold badge22 silver badges45 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

One you understand how DynamoDB operates, the questions will almost answer themselves.

DynamoDBs architecture is built on a leader - follower model. All writes are written to the leader node for any given partition replica group.

When you do a strongly consistent read, you will always read from the leader also. This guarantees that you will be returned any data that was successfully written before it.

  1. It depends if another write happened after X but before the read, from any thread. Strongly consistent reads will return the result of all actions that happened before it got there.

  2. Yes, again the read happens after Wx but before Wy so you get the image which is on disk, which is the result of Wx.

  3. Yes, however the Lambda should have the entire result of W which does not necessitate an additional read.

发布评论

评论列表(0)

  1. 暂无评论