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.

asked 2 years ago391 views
1 Answer
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
answered 2 years ago
  • 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.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions