In this post we’ll change the topic and instead of implementation details we presented recently, we are going to analyze the prices for 2 of the most used AWS services. Does this sound like comparing apples and oranges? Nothing better! Go ahead and read this to the end to convince if you are right or not.
S3 is the good fit when you intend to store unstructured objects, whereas DynamoDB is the choice when you deal with (semi-)structured data, that need to be handled with low latency. At this time, maximum size for one item is 5 Tb, while DynamoDB limits this to 400Kb. Therefore, DynamoDB and S3 have different specifications and limitations, deal with different use cases, but share a common feature: high durability.
Having this in mind, let’s consider a scenario: our application receives on average 100 requests per seconds, with 2Kb payload and is required to persist it entirely. Also, each object saved is read 2 times. Using the AWS calculator, we can estimate the monthly storage cost for DynamoDB and S3. 100 requests/seconds means 259.2M requests in a month and 494.3Gb of storage. We chose us-east-1 region.
And now the big surprise: S3 costs 1762$/month, whereas DynamoDB costs 298$/month. In the S3 case, the biggest cost part comes from accessing the service, the storage itself being under 100$/month.
We considered the same scenario and calculated the costs, but having requests with different payload: 5Kb, 10Kb, 20Kb and 50Kb. As you can see from the below chart, it is cheaper to save items under 20Kb in DynamoDb, but when the request size becomes larger, the DynamoDB price grows linearly, whereas growth costs for S3 is less significant.
To sum up: before deciding what solution fits better your use case, try to understand the requests pattern you’ll have and dive deep into the cost model for each possible solution, because as we proved above, the difference in some cases could be important (just compute the difference if your service handles 1000 requests/second) and in most cases, costs are good argument for choosing one approach or another.
We hope it worth reading this and, as always, don’t hesitate to send us your comments and ideas on this topic!