0
0
DynamodbHow-ToBeginner ยท 4 min read

How to Estimate DynamoDB Cost: Simple Guide

To estimate DynamoDB cost, calculate charges based on read/write capacity units, data storage, and data transfer. Use the AWS Pricing Calculator or multiply your expected usage by the unit prices listed on the AWS DynamoDB pricing page.
๐Ÿ“

Syntax

The main factors to estimate DynamoDB cost are:

  • Read Capacity Units (RCUs): Number of strongly consistent reads per second.
  • Write Capacity Units (WCUs): Number of writes per second.
  • Storage: Amount of data stored in GB.
  • Data Transfer: Data sent out of AWS.

Cost formula example:

Cost = (RCUs ร— RCU price) + (WCUs ร— WCU price) + (Storage GB ร— Storage price) + (Data Transfer ร— Transfer price)
text
Cost = (ReadCapacityUnits ร— PricePerRCU) + (WriteCapacityUnits ร— PricePerWCU) + (StorageGB ร— PricePerGB) + (DataTransferGB ร— PricePerGBTransfer)
๐Ÿ’ป

Example

This example estimates monthly cost for a DynamoDB table with 100 RCUs, 50 WCUs, 10 GB storage, and 5 GB data transfer out.

javascript
const pricePerRCU = 0.00013; // USD per RCU-hour
const pricePerWCU = 0.00065; // USD per WCU-hour
const pricePerGBStorage = 0.25; // USD per GB-month
const pricePerGBTransfer = 0.09; // USD per GB data transfer out

const RCUs = 100;
const WCUs = 50;
const storageGB = 10;
const dataTransferGB = 5;

const hoursInMonth = 24 * 30;

const costRCU = RCUs * pricePerRCU * hoursInMonth;
const costWCU = WCUs * pricePerWCU * hoursInMonth;
const costStorage = storageGB * pricePerGBStorage;
const costTransfer = dataTransferGB * pricePerGBTransfer;

const totalCost = costRCU + costWCU + costStorage + costTransfer;

console.log(`Estimated monthly cost: $${totalCost.toFixed(2)}`);
Output
Estimated monthly cost: $69.60
โš ๏ธ

Common Pitfalls

Common mistakes when estimating DynamoDB costs include:

  • Ignoring the difference between on-demand and provisioned capacity pricing models.
  • Not accounting for burst capacity or auto scaling effects.
  • Forgetting data transfer costs, especially for cross-region or internet traffic.
  • Underestimating read/write unit consumption due to item size or consistency settings.
javascript
/* Wrong: Assuming 1 RCU = 1 read regardless of item size */
const itemSizeKB = 4; // 4 KB item
const readsPerSecond = 100;
const RCUsNeededWrong = readsPerSecond; // Incorrect

/* Right: Calculate RCUs based on item size (1 RCU = 4 KB strongly consistent read) */
const RCUsNeededRight = Math.ceil(readsPerSecond * (itemSizeKB / 4));
๐Ÿ“Š

Quick Reference

FactorUnitTypical Price (USD)
Read Capacity Unit (RCU)Per hour$0.00013
Write Capacity Unit (WCU)Per hour$0.00065
Data StoragePer GB-month$0.25
Data Transfer OutPer GB$0.09
โœ…

Key Takeaways

Estimate DynamoDB cost by multiplying capacity units, storage, and data transfer by their prices.
Use the AWS Pricing Calculator for accurate and updated cost estimates.
Remember to consider your capacity mode: on-demand or provisioned.
Account for item size and read consistency when calculating capacity units.
Include data transfer costs, especially for cross-region or internet traffic.