Can we achieve strong write consistency in DynamoDB?

0

We have an http PATCH service that sets a record as "disabled" in a DynamoDB table. And we have a GET endpoint that retrieves records from that table. We would like to ensure that users cannot pull records that are underway of being changed or have recently been updated to disabled. I understand there is a strongly consistent read option, but are there any options/ideas available to acheive that consistency with write operations? One possibility we considered is doing a strongly consistent read immediately following the UpdateItem command. We also looked at DAX but that only offers eventual consistency.

We would like our reads to be performant, so the strongly consistent read option is not ideal. We are not as concerned with performance for write operations.

Brent
已提問 6 個月前檢視次數 700 次
1 個回答
1

While all writes to DynamoDB are strongly consistent, I believe what you want is the item as it was directly after the update. One such solution is what you mention, a strongly consistent read directly after the update, which will cost you an additional read request.

I believe the best way to do this is to use the ReturnValues parameter of the UpdateItem API:

Use ReturnValues if you want to get the item attributes as they appear before or after they are successfully updated. For UpdateItem, the valid values are:

  • NONE - If ReturnValues is not specified, or if its value is NONE, then nothing is returned. (This setting is the default for ReturnValues.)
  • ALL_OLD - Returns all of the attributes of the item, as they appeared before the UpdateItem operation.
  • UPDATED_OLD - Returns only the updated attributes, as they appeared before the UpdateItem operation.
  • ALL_NEW - Returns all of the attributes of the item, as they appear after the UpdateItem operation.
  • UPDATED_NEW - Returns only the updated attributes, as they appear after the UpdateItem operation.

There is no additional cost associated with requesting a return value aside from the small network and processing overhead of receiving a larger response. No read capacity units are consumed.

profile pictureAWS
專家
已回答 6 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南