How On-Demand Pricing Slashed our DynamoDB Bill by 90%

Ashwin Bhat
Mar 13, 2019 · 4 min read

At Koan, we use DynamoDB for all of our application’s database needs. It’s fully managed, helping us maintain reliable query latency regardless of traffic volume and reduce our operational workload. But one of the challenges we’ve had to deal with has been around capacity planning. Our traffic pattern is generally very spiky: we see our highest usage on Mondays and Fridays, with the middle of the week and weekends being low points.

Image for post
Image for post
User sessions over the last month

This usage pattern complicates capacity planning. We’re generally either over-provisioned, and thus wasting money, or under-provisioned, and thus risking our queries being throttled as auto-scaling kicks in.

Enter On-Demand Mode

This pricing structure seemed perfect for us: high performance when we need it, and no wasted money from over-provisioning. So did it actually live up to the claims?

Image for post
Image for post
Can you guess when we switched pricing modes?

In January, we dipped our toe into this new world by enabling on-demand pricing on our most used tables. We saw an immediate dip in our costs, so at the end of February we enabled it for the rest of our tables. When all was said and done, our average daily cost was down about 90%! From our testing, we were unable to detect any hits to performance either. Overall, a huge win.

On-Demand Mode Tips

Our service has very spiky traffic, so on-demand mode is ideal for us. If your service has a level traffic load, on-demand mode will probably end up costing you more money, not less. As an extreme example, suppose we have a table with 1000 Read Capacity Units (RCUs) and 1000 Write Capacity Units (WCUs). Per Amazon’s pricing, this would cost us $561.60 per month in total. With that capacity, if our traffic were perfectly even, and our capacity were fully utilized, we’d be able to perform 5,184,000,000 reads per month and 2,592,000,000 writes per month. If we were using on-demand pricing, we’d be paying $4,536 per month. That’s over 9x the price! This is a very contrived example, but the overall lesson is clear: on-demand mode is only worth it if your traffic is very uneven.

Over-provision like there’s no tomorrow before switching to on-demand mode

Under the hood, DynamoDB maintains capacity equal to double your previous peak traffic when in on-demand mode. When you exceed this amount, it can take up to 30 minutes to scale up to meet your new peak. But there’s a subtle detail in the documentation around how it provisions capacity when you first switch over to on-demand mode: the capacity it initially provisions will be whatever your capacity was immediately before you switched. This means that if you scale up to 10,000 RCUs and WCUs in every index just before flipping the switch, your capacity in on-demand mode will stay at 10,000, even if your peak traffic is typically much lower than that. As best we can tell, there’s no drawback to this trick.

Switch back to provisioned mode for scheduled operations

On-demand mode is great for handling spiky user traffic, but it’s much more expensive per-query than a fully utilized provisioned capacity setup. When performing operations such as large backfills or data migrations, it may be cheaper to switch to provisioned mode with just the right estimated capacity that you’ll need for your operation. DynamoDB allows you to switch back and forth once per day, so a well-timed switchover could save you a lot of money.


On-Demand pricing has been great for us so far, but we’ll keep re-evaluating it as our traffic patterns shift. We’re also continuing to explore all the ways we can get more value out of DynamoDB. Check back soon for an exploration of how we’ve modeled our database schema to achieve scalability without sacrificing flexibility.

Image for post
Image for post

Koan drives transparency, boosts engagement, and helps leaders at every level achieve amazing results. Share your mission and vision, deliver strategic OKRs, and discover more purposeful work at www.koan.co.

Developing Koan

Dispatches from the Koan Engineering team

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store