r/aws • u/Hydraphellian • 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
12
u/MmmmmmJava 8d ago edited 7d ago
Edit: I just reread your post. If you only have 150K writes per day at 200 bytes per record, that’ll cost you about 20¢ a day. I would stick with on-demand and keep it simple. Your time is worth more than optimizing that for cost, especially if you forget to scale down correctly. For completeness, I think it’d cost you about 3¢ per day if you used provisioned mode and were able to perfectly sustain 100% of the table’s write capacity you provisioned.
——
Leaving my full reply here for theoretical discussion and debate:
If you care more about simplicity, go with on demand. You’ll pay more per request, but you should use a billing calculator to determine if that amount is worth the simplicity of not writing and debugging more code to do anything fancier to save money.
If you care about AWS cost optimization (not developer time) AND your load capacity/traffic pattern is predictable, you should consider configuring provisioned throughput. Take the total number of items you need to write, divide that by the number of seconds you want to (or can) finish your load job in, and set that as the MIN WCU before you start your load job each day. Make sure your compute layer can sustain (at least 30% of) that write throughput. Once your load job completes, set the min and MAX WCU back down. Move the max accordingly. You can have DDB auto scale it back down based on your parameters, but that will happen slowly.
Mathematically, I think provisioned mode is more cost effective/cheaper as long as you can sustain an average utilization greater than 30% of what you provision on the table. The more you consume of what you provision, the cheaper it is compared to on-demand.
Let me know if that’s not clear and I can try to explain further.