thebeancounter
thebeancounter

Reputation: 4829

dynamodb update denormalized data and keep consistency

I am using dynamodb with python API and denormalize my data in order to keep the reads fast. The think is that I am worried about keeping the consistency when updating my data say i have a table of users, each has a key and a name, and a table of purchases each has a key and a data containing buyer key (user) and the buyer's name.

I would like to update the user's name and update all his purchases using an atomic operation, like available in firebase (multi path update) explained here

How can I do that?

Thanks

Upvotes: 4

Views: 1058

Answers (1)

best wishes
best wishes

Reputation: 6624

Here is a nice documentation of dynamodb transaction.

Here are few highlights of the blog post.

  1. Dynamodb supports transaction capability across multiple table where you can also have pre-condition on every insert (i.e. insert into order table only if prev_snapshot=1223232, this will make sure you are modifying the last read data only.)

  2. There are 2 types of gets supported TransactGetItems and Eventual/Strongly consistent GetItem. In TransactGetItems, if a transaction is in progress the request is rejected. while in the other 2 cases last committed data is returned based on your consistency requirements.

  3. Transactions are not locks if some other thread is writing to a table without transaction, and if write succeeds before transaction is completed, and exception will be thrown on transaction.

  4. No extra steps/permissions are required to enable transaction on a single region table.

  5. Cost will double for every read and write whiles using transactional capabilities.

Here are the features which are not supported

  1. Transactional capabilities in global table. but this can be avoided by request stickiness and should not be a big issue IMO.

Upvotes: 2

Related Questions