
Answer-first summary for fast verification
Answer: Use TransactWriteItems API of DynamoDB Transactions
Correct option: Use TransactWriteItems API of DynamoDB Transactions With Amazon DynamoDB transactions, you can group multiple actions together and submit them as a single all-or-nothing TransactWriteItems or TransactGetItems operation. TransactWriteItems is a synchronous and idempotent write operation that groups up to 25 write actions in a single all-or-nothing operation. These actions can target up to 25 distinct items in one or more DynamoDB tables within the same AWS account and in the same Region. The aggregate size of the items in the transaction cannot exceed 4 MB. The actions are completed atomically so that either all of them succeed or none of them succeeds. You can optionally include a client token when you make a TransactWriteItems call to ensure that the request is idempotent. Making your transactions idempotent helps prevent application errors if the same operation is submitted multiple times due to a connection time-out or other connectivity issue. Incorrect options: Use BatchWriteItem API to update multiple tables simultaneously - A TransactWriteItems operation differs from a BatchWriteItem operation in that all the actions it contains must be completed successfully, or no changes are made at all. With a BatchWriteItem operation, it is possible that only some of the actions in the batch succeed while the others do not. Capture the transactions in the players table using DynamoDB streams and then sync with the items table Capture the transactions in the items table using DynamoDB streams and then sync with the players table Many applications benefit from capturing changes to items stored in a DynamoDB table, at the point in time when such changes occur. DynamoDB supports streaming of item-level change data capture records in near-real-time. You can build applications that consume these streams and take action based on the contents. DynamoDB streams cannot be used to capture transactions in DynamoDB, therefore both these options are incorrect.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A development team is in the process of creating a game that allows players to purchase items using virtual coins. Each time a user buys a virtual coin, it is necessary to update both the players table and the items table in DynamoDB simultaneously and ensure that these updates occur as an all-or-nothing transaction.
As a developer associate, what approach would you take to implement this functionality?
A
Use TransactWriteItems API of DynamoDB Transactions
B
Use BatchWriteItem API to update multiple tables simultaneously
C
Capture the transactions in the players table using DynamoDB streams and then sync with the items table
D
Capture the transactions in the items table using DynamoDB streams and then sync with the players table