How do I minimize my DynamoDB costs?

4 minute read
0

I want to minimize my costs in Amazon DynamoDB, but I'm not sure how.

Short description

First, use the AWS Pricing Calculator estimate your costs for DynamoDB.

Then, take the following actions to minimize your DynamoDB costs:

  • Choose the correct capacity mode and table access.
  • Use maximum throughput.
  • Reduce the size of your global secondary index.
  • Configure your applications to use the Query operation.
  • Use Time to Live (TTL) to remove old data.
  • Use AWS owned keys for encryption at rest.
  • Store large objects in Amazon Simple Storage Service (Amazon S3).
  • Use short attribute names.
  • Use cost allocation tags.
  • Use AWS Budgets and AWS Cost Explorer.

DynamoDB charges to read, write, and store your data in DynamoDB tables. DynamoDB also charges for additional features that you turn on. Optional features, such as global tables and streams, are billed based on their respective units. Based on the instance type you select, DynamoDB Accelerator (DAX) is billed by the hour.

Resolution

Choose the correct capacity mode and table class

To process reads and writes on your tables, DynamoDB has two capacity modes that have specific billing options, on-demand and provisioned. Make sure to choose the correct capacity mode for your needs. On-demand capacity mode works well for unpredictable workloads. For predictable workloads, use provisioned or provisioned with auto scaling. For steady workloads, you can also use reserved capacity.

You're billed for read and write request units and storage fees based on your table class. So, make sure that you're using the correct table class for your needs. 

Use maximum throughput

Use maximum throughput for on-demand tables. Maximum throughput can optimize your throughput costs, help reduce excessive usage, and safeguard downstream services.

Reduce the size of your global secondary index

To reduce the size of your global secondary index, use KEYS_ONLY or INCLUDES instead of ALL. The reduction uses less read and write capacity units.

Configure your applications to use the Query operation

A Scan operation scans the entire table or secondary index, and then filters out values for your results. For faster response times and reduced costs, configure your tables and indexes to let your applications use the Query operation.

Use TTL to remove old data

If you have a requirement to remove old data, then use TTL

Use AWS owned keys for encryption at rest

Depending on your use case, you can use an AWS owned key for encryption at rest. AWS owned keys are included at no additional charge. However, AWS managed and customer managed keys can incur AWS Key Management Service (AWS KMS) charges. If you use global tables, then the tables call AWS KMS for the replicated writes and can result in AWS KMS charges.

Store large objects in Amazon S3

If you store large objects, then store them in Amazon S3 and store the S3 URL in DynamoDB.

Use short attribute names

Attribute names contribute to the total size of an item. To minimize costs, use shorter attribute names. Long attribute names increase storage costs and the number of write and read capacity units that are used.

Use cost allocation tags

To quickly see your DynamoDB costs, use cost allocation tags.

Use AWS Budgets and AWS Cost Explorer

Use AWS Budgets to set custom spending plans on AWS for a specific period. If your costs or usage exceeds or is projected to exceed your spending limit, then you receive an alert.

Use AWS Cost Explorer to analyze your account's resource usage and costs over time. For more information, see Best Practices for understanding your AWS Billing and Usage Reports.

Related information

DynamoDB on-demand and provisioned capacity

Amazon DynamoDB pricing

Cost Optimization with AWS

Event series: AWS Cost Optimization

AWS OFFICIAL
AWS OFFICIALUpdated 5 months ago
No comments