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

    ☎️ Serverless Clarity Call

    Need quick guidance on a specific issue on your AWS serverless project? Or just wondering where to start with serverless?

    Book a call and ask me anything.

    Learn more >>

    🛫 Serverless Launchpad

    Ready to start building your new AWS serverless project but need help with getting everything setup?

    The Serverless Launchpad is a done-for-you DevOps service installed in under a week. You get a leading-practice multi-account AWS environment, a scaffolded codebase and architecture including the common AWS serverless services, isolated cloud environments for individual developers, automated delivery pipelines right through to production and much more. Everything is IaC, extensively documented and handed over to your developers.

    Learn more >>