How to do an atomic DynamoDB transaction with more than 25 items

Today’s email is a short one to be filed under your “I hope I don’t ever need to do this, but if I do at least I have this link as a starting point” list 🙂.

DynamoDB allows you to write (Put, Update or Delete) multiple items across multiple tables within a single atomic transaction using its TransactWriteItems API operation. However, this operation has a limit of 25 items and I recently hit a use case where I needed to atomically update a number larger than this, so I started researching solution options and asked the question on Twitter, to which a few DynamoDB experts chimed in.

The high-level approach I’m settling on is to use a client-observed pessimistic locking strategy which is co-ordinated by a Step Functions state machine. You can read the details of this approach and some other considerations in my note here:

A short disclaimer—this is a note with my WIP thoughts (informed by my Twitter responders) and I haven’t implemented or tested this solution yet. It’s not a well-structured blog post nor is it a comprehensive generic solution for all use cases, but I share it in the spirit of giving you a starting point if you ever hit this requirement.

— Paul

Join daily email list

I publish short emails like this on building software with serverless on a daily-ish basis. They’re casual, easy to digest, and sometimes thought-provoking. If daily is too much, you can also join my less frequent newsletter to get updates on new longer-form articles.

    View Emails Archive

    Architecture & Process Review

    Built a serverless app on AWS, but struggling with performance, maintainability, scalability or DevOps practices?

    I can help by reviewing your codebase, architecture and delivery processes to identify risk areas and their causes. I will then recommend solutions and help you with their implementation.

    Learn more >>

    🪲 Testing Audit

    Are bugs in production slowing you down and killing confidence in your product?

    Get a tailored plan of action for overhauling your AWS serverless app’s tests and empower your team to ship faster with confidence.

    Learn more >>