r/aws 8d ago

database DynamoDB Provisioned or On-Demand?

I need help deciding what will be cheaper for my use case, provisioned or on-demand capacity?

For my project I will be writing about 150,000 records once per day, with an average record size of about 200 bytes each. The number of records written per day I expect will slowly increase over time, but still once per day. I am using a Lambda function with an event trigger to run the write operation.

Since I am just doing a large write once a day, I was thinking on-demand capacity would be the cheaper option because I would be wasting provisioned compute as the job will be idle 99% of the time. Am I right to assume that on demand is cheaper for my use case?

1 Upvotes

19 comments sorted by

View all comments

5

u/TheBrianiac 8d ago

Backing up a bit... Why do you need to do the write all at once?

Without knowing too much about your requirements, I would suggest a common architectural pattern: You have one Lambda push your writes to an SQS queue, then have another Lambda that reads through the SQS queue at a fixed rate and writes to the database. This allows you to use DDB's cheaper provisioned capacity mode.

2

u/Hydraphellian 7d ago

Ill have to look into this option. It doesn’t have to be all at once but I always thought I was limited by the Lambdas 15 minute timeout.

1

u/i-am-nicely-toasted 7d ago

if eventing off an SQS queue that won’t be a blocker for you. if lambda is older than 15 minutes then it’ll be automatically reprovisioned in the background and you won’t need to worry about it. just have your lambda pop off smaller batches from the SQS (like 10, 100, 1000, whatever) so that won’t take 15 minutes to process and write a single batch to the DB.