Skip to main content

DynamoDB Capacity Units Calculator: RCU, WCU & Cost Guide

DynamoDB's capacity model — Read Capacity Units and Write Capacity Units — determines both performance and cost. Understanding how item sizes map to capacity consumption is essential to avoid throttling and bill surprises.

✓ RCU & WCU calculation formulas ✓ On-Demand vs Provisioned pricing ✓ Auto-scaling configuration ✓ Cost optimization with TTL & sparse indexes

RCU and WCU Calculation Rules

Operation Capacity Rule Example: 3KB item Example: 7KB item
Strongly consistent read1 RCU per 4KB1 RCU2 RCUs
Eventually consistent read0.5 RCU per 4KB0.5 RCU1 RCU
Transactional read2 RCUs per 4KB2 RCUs4 RCUs
Write (PutItem/UpdateItem)1 WCU per 1KB3 WCUs7 WCUs
Transactional write2 WCUs per 1KB6 WCUs14 WCUs

On-Demand vs Provisioned Pricing

Mode Read Cost Write Cost Best For Risk
On-Demand$0.25/M RRUs$1.25/M WRUsSpiky / unpredictable5-10x higher at sustained load
Provisioned$0.00013/RCU-hr$0.00065/WCU-hrPredictable trafficOver/under-provision risk

Provisioned Capacity with Auto Scaling

# Terraform: DynamoDB with auto-scaling
resource "aws_dynamodb_table" "users" {
  name           = "users"
  billing_mode   = "PROVISIONED"
  read_capacity  = 5     # Minimum provisioned
  write_capacity = 5

  hash_key  = "id"

  attribute {
    name = "id"
    type = "S"
  }

  ttl {
    attribute_name = "expiresAt"  # TTL = free deletes
    enabled        = true
  }
}

# Auto-scaling policy (scales between 5-100 WCU)
resource "aws_appautoscaling_target" "dynamodb_write" {
  max_capacity       = 100
  min_capacity       = 5
  resource_id        = "table/${aws_dynamodb_table.users.name}"
  scalable_dimension = "dynamodb:table:WriteCapacityUnits"
  service_namespace  = "dynamodb"
}

resource "aws_appautoscaling_policy" "dynamodb_write_policy" {
  name               = "DynamoDBWriteCapacityUtilization"
  policy_type        = "TargetTrackingScaling"
  resource_id        = aws_appautoscaling_target.dynamodb_write.resource_id
  scalable_dimension = aws_appautoscaling_target.dynamodb_write.scalable_dimension
  service_namespace  = aws_appautoscaling_target.dynamodb_write.service_namespace

  target_tracking_scaling_policy_configuration {
    predefined_metric_specification {
      predefined_metric_type = "DynamoDBWriteCapacityUtilization"
    }
    target_value = 70.0  # Scale when 70% utilized
  }
}

Cost Optimization Strategies

// 1. Use eventually consistent reads (half the RCU cost)
const result = await dynamoDB.get({
  TableName: 'users',
  Key: { id: { S: userId } },
  ConsistentRead: false  // Eventually consistent = 0.5 RCU (default)
  // ConsistentRead: true = 1 RCU (use only when freshness required)
}).promise();

// 2. Project only needed attributes
const result = await dynamoDB.query({
  TableName: 'orders',
  KeyConditionExpression: 'userId = :uid',
  ExpressionAttributeValues: { ':uid': { S: userId } },
  // Only fetch what you need — reduces data transfer and effective RCU
  ProjectionExpression: 'orderId, #s, amount',
  ExpressionAttributeNames: { '#s': 'status' },
}).promise();

// 3. Use TTL for auto-cleanup (0 WCU for deletes)
const item = {
  id: { S: sessionId },
  userId: { S: userId },
  data: { S: JSON.stringify(sessionData) },
  // TTL: Unix timestamp — DynamoDB deletes automatically (free!)
  expiresAt: { N: String(Math.floor(Date.now() / 1000) + 86400) }
};
Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →

Frequently Asked Questions

What is a Read Capacity Unit (RCU)?▼

One Read Capacity Unit (RCU) represents the throughput for one strongly consistent read per second for items up to 4KB. Eventually consistent reads use half an RCU. For items larger than 4KB, AWS rounds up to the next 4KB boundary — a 5KB item costs 2 RCUs for a strongly consistent read, or 1 RCU eventually consistent. For transactional reads (TransactGetItems), each read consumes 2 RCUs.

What is a Write Capacity Unit (WCU)?▼

One Write Capacity Unit (WCU) represents one write per second for items up to 1KB. Larger items require proportionally more WCUs — a 3.5KB item rounded up to 4KB costs 4 WCUs. Transactional writes (TransactWriteItems) consume 2 WCUs per item. Conditional writes that fail still consume WCUs. Batch writes (BatchWriteItem) are not transactional but each item still consumes 1 WCU per KB.

When should I use On-Demand vs Provisioned capacity?▼

On-Demand capacity is ideal for unpredictable traffic, new tables without traffic baselines, spiky workloads, and development/test environments. It costs roughly $1.25 per million read requests and $1.25 per million write requests. Provisioned capacity with Auto Scaling is better for predictable sustained traffic — it can be 5-10x cheaper at steady load. On-Demand can be up to 7x more expensive per operation than well-provisioned Provisioned mode.

How do Global Secondary Indexes affect capacity?▼

GSI reads are billed from the GSI's own capacity pool, not the table's. If you provision 100 WCUs on a table and add a GSI that updates on every write, those GSI writes also consume capacity — from the GSI's provisioned capacity. In On-Demand mode, GSI operations are charged at the same per-request rates. Over-projecting attributes to GSIs wastes write capacity since every projected attribute is replicated on writes.

How does DynamoDB TTL affect capacity?▼

DynamoDB TTL deletions are performed in the background and do not consume Write Capacity Units. DynamoDB deletes expired items within 48 hours of expiration. TTL is one of the most effective cost optimization strategies — use it to automatically expire session data, temporary tokens, rate limit counters, and any time-bound records rather than deleting them manually with WCUs.

What is the DynamoDB pricing for storage?▼

DynamoDB storage costs $0.25 per GB/month. The first 25GB is free under the AWS Free Tier. For large tables, storage can exceed the per-request cost. Optimize storage by: keeping item sizes small (avoid storing large blobs — use S3 instead), using sparse indexes (only index items that need the GSI), compressing large attributes, and using TTL to expire obsolete data.