user25636893
user25636893

Reputation: 1

DynamoDB local: how are computed consumed capacity units in Transactions?

I'm using local DynamoDB with the AWS SDK for Javascript 2.1062.0. I've read in the documentation and other sources that an operation in a transaction consumes twice as many Write Capacity Units (WCUs) as a single equivalent operation: 1 to prepare the transaction + 1 to the validation.

However, I must be missing something with the API consumed capacity returns.

I have a table with 2 global secondary indexes.

If I push a very basic item (only the Partition Key PK and the sort Key SK) with a PutItem request, the API reports a consumption of 1 WCU. But if I do the exact same operation in a transaction with TransactWriteItems, the response mentions 4 WCUs instead of the expected 2. If I also specify the keys of the secondary indexes (PK1/SK1 + PK2/SK2), the API reports a consumption of 3 WCU for a simple PutItem request and 12 (instead of the expected 6) for the same Put in TransactWriteItems. However, if I add 2 additional Put operations (PK + SK) into the transaction, each consumes 2 WCU as expected.

To sum up:

1 PutItem for item1(PK + SK) => reported: 1 WCU, expected: 1 1 Put in TransactWriteItems for item1(PK + SK) => reported: 4, expected: 2 1 Put in TransactWriteItems for item1(PK + SK + PK1 + SK1 + PK2 + SK2) => reported: 12, expected: 6 3 Put in TransactWriteItems for item1(PK + SK + PK1 + SK1 + PK2 + SK2) + item2(PK + SK) + item3(PK + SK) => reported: 16, expected: 10

In the AWS document, example 1 is a transaction with an Update operation and a Delete operation that yields 10 WCU. Can anyone explain this result? https://docs.aws.amazon.com/cli/latest/reference/dynamodb/transact-write-items.html

Thank you in advance for your feedback.

I tried to reduce the operations to the essentials as decribed in the question to see where the x4 factor could come from but I didn't succeed.

Upvotes: 0

Views: 95

Answers (0)

Related Questions