aws-lambdaconcurrencyamazon-dynamodb

transactional lambda in aws dynamodb to generate a counter of new records from one table to another table?


In dynamodb I have a "votes" table that records a unique email, and only one option (out of 10 possible), in the hypothetical case that more than 1000 votes are made per second, I could execute a lambda that is activated every 25 new records and accumulate the number of votes (option) received in another table "election" that contains 10 elements (the options) and a value attribute that would be the accumulator? The question is how I do a writing concurrency control so that votes are not lost. Would transactional writing prevent this for this many votes per second?

The tables would be on-demand.

thanks!

Do not carry out tests for cost reasons before trying it


Solution

  • Every key in DynamoDB can provide you 1000 WCU. Since you refer to your key as a unique email, I find it highly unlikely a single user will vote more than 1000 times per second.

    UpdateItem in DynamoDB is atomic, and strongly serialized. This means that you will not lose updates based on concurrency, all updates will succeed to matter how high the concurrency so long as it's not more than 1000 per second to induce throttling.