DynamoDB Global Tables and Counters

0

Greetings!

I've created a DynamoDB table that manages counters. These counters have to be strongly consistent - the workflow currently is to update the counter and read the new value of the counter that is returned by the update.

At some point I would like to go multi-region with my application and the next logical step is to convert my existing tables to global tables, but I have concerns that this particular counter table will not work on a global scale.

My question is that if I convert this table to a global table and multiple requests across regions attempt to increment this counter, can I expect that it is possible two update requests may return the same value across regions?

Unhappy path example:

  • Counter = 1
  • Request to increment counter by 1 in region A and B at the same time
  • Request succeeds and the returned value for Region A and B is 2

This would be bad, we need Region A to get 2 and Region B to get 3.

已提問 2 年前檢視次數 406 次
1 個回答
1

Interesting question. You should not expect reads to be strongly consistent across regions, There could be delays replicating data across regions ( even though ms). Can you have region specific counters, or update counters in only one region? You may also need to put your logic in a transaction and transactional operations provide atomicity, consistency, isolation, and durability (ACID) guarantees only within the region where the write is made originally. Transactions are not supported across regions in global tables.

AWS
已回答 2 年前
  • Thank you for the quick response! The counters can't be region specific, but I can definitely update counters in one region - it may make sense to provision the table in a central region to help with latency from requests across regions.

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

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

回答問題指南