Amazon DynamoDB | Can This NoSQL Database Be Used For Free?

Is AWS DynamoDB Free?

Cloud based services, especially databases, can be cost effective when compared to self managed and self hosted services when considering all of the operational overhead, redundant power, redundant networking, support and maintenance required to host and maintain them. But can a service like Amazon DynamoDB which provides all of these features really be free to use?

AWS Dynamo DB has an always free use tier that provides customers with 25GB of Storage, 25 provisioned Write Capacity Units and 25 provisioned Read Capacity Units per month at zero cost. This is enough free usage for 200 million requests per month.

For most users, two hundred million requests a month may be plenty to support the traffic that visits their site or application. But what is a provisioned Write Capacity Unit? What is a provisioned Read Capacity?

AWS Free Tier

Amazon Web Services, or AWS for short, provides something called the AWS Free Tier. This offers access to many of the AWS services for no cost. However, most of the items listed have a 12 month time limit on that free usage. Once the 12 month clock has expired, the customer is required to start paying for the services used.

Amazon DynamoDB has an exception to this. It is offered on an always free tier for certain parts of the database service. As mentioned, this includes a total of 25 GB of storage from the DynamoDB service. This also includes 25 provisioned write capacity units (WCU) and 25 provisioned read capacity units (RCU).

A write capacity unit is defined by AWS as one write per second for records of up to 1KB in size. This means that for free, Amazon DynamoDB allows you to write twenty five 1KB sized items into the database per second every month for free. Given that a day has 86400 seconds, and there are approximately 30 days in a month, a customer could issue up to 64.8 million write events in a single month for free, if limited to 25 writes per second.

However when doing this with 1KB sized items, if all of these writes events were to create new object records it would create approximately 61.8GB of data in the DynamoDB database during this month period. A benefit though is that some of these writes would most likely be updates instead of only creates, which could prevent going over the free storage limit provided by the AWS free tier.

Looking at read capacity units, these are defined by AWS as one strongly, or two eventually, consistent reads per second, for records stored of up to 4KB in size. This means that the AWS Free Tier for Amazon DynamoDB allows for strongly reading twenty five 4KB items per second every month or 50 eventually consistent reads per second every month for free. Using the same math as before, this works out to the same 64.8M when looking at strongly consistent reads, but increases to 129.6M eventually consistent reads if using that type. Putting these call amounts together, we can see where the two hundred million free monthly calls comes from.

As you can see AWS has a lot to offer when it comes to their AWS Free Tier for Amazon DynamoDB.

Capacity Units For Larger Items

What happens if reads or writes of records to the DynamoDB database are larger than the sizes described in the capacity unit definitions? Well this causes either extra read or write capacity units to be consumed for the call depending on what type of request was made to the Amazon DynamoDB service.

For the write capacity type requests, every item size is broken into 1KB chunks and the number of 1KB chunks rounded up equates to the number of request units charged for the request. For example if the record written to Amazon DynamoDB was 25.4KB in size, this would take twenty six 1KB chunks of write capacity and therefore use 26 write capacity units for this request.

Read capacity type requests on the other hand are broken into 4KB chunks. So the number of 4KB chunks rounded up ends up being the number of read capacity units used for the given read request. If a strongly consistent read request was issued for a 20.4KB item that was stored in Amazon DynamoDB, this would be broken into six 4KB chunks, meaning 6 read capacity units would be used for this strongly consistent read. However using an eventually consistent read on the same item would only require half of the read capacity.

In both cases however, these larger items can still be read with the AWS Free Tier provided to Amazon DynamoDB. This means that even these larger items can be read and written for free into and out of Amazon DynamoDB!

Exceeding The Provisioned Free Capacity

You may be wondering what happens if your Amazon DynamoDB table is provisioned for the 25 read capacity units and 25 write capacity units, but the load on your application or website tries to exceed that capacity. For example if the application or website tries to make more than 25 reads per second, or tries to make more than 25 writes per second, or tries to strongly read a single 100KB item every second.

In any of these situations, the Amazon DynamoDB service will start throttling the requests made to the database table. So instead of actually having your data written to the database or returned with the read request, a throttle error will be returned. This is an indication to your systems that you should start thinking about backing off your requests, usually at an exponential rate.

This may not be an ideal situation for your customers, but it will keep your Amazon DynamoDB table costs free since you won’t be allowed to exceed the free tier capacity allotment from either reads or writes. Not all is lost though. The Amazon DynamoDB service does allow bursting above the provisioned capacity to happen in certain situations.

This normally happens when there was an idle period before the burst requirement. Some of the provisioned capacity that was not previously used gets added to a credit pool which can be used to burst above the normal capacity limits. However this pool of credit capacity has a maximum limit and does not keep growing indefinitely when there is no activity happening against the Amazon DynamoDB table.

Sharing The Free Capacity

Even though the information provided in this article has mostly been described against a single DynamoDB table, it is not required to only have the 25 read capacity units and 25 write capacity units used on a single table to still take advantage of the AWS Free Tier provided to Amazon DynamoDB. This capacity can be spread across several tables.

This will work, and remain free, as long as the total capacity units between the tables does not exceed the 25 write capacity units and 25 read capacity units in total. So the website or application could be designed to have one table with 10 write capacity units and 15 read capacity units and another table configured with 15 write capacity units and 10 read capacity units and still be within the AWS Free Tier available to Amazon DynamoDB customers.

One other thing to watch out for here to stay within the free usage limits is to keep under the 25GB of storage in these tables even if that is split across several tables in the Amazon DynamoDB account. This also includes any indexes enabled on these tables as these indexes take up storage space just like the original data records do. This would hold for local secondary indexes as well as global secondary indexes.

These indexes mostly make copies of the original data records, but store them in a different order for faster retrieval for some of the requests that are made against the indexes. The indexes are not required to retain full copies of the original records, so it probably makes sense to only store the data that is absolutely required by the index in order to remain within the free storage limit of Amazon DynamoDB which is a maximum of 25GB of storage.