DynamoDB Scaling
Last updated
Was this helpful?
Last updated
Was this helpful?
DynamoDB scaling operates across two primary dimensions:
Throughput Capacity: Managed through read and write capacity units
Storage Size: Individual items capped at 400KB, with unlimited total storage potential
Each partition is a 10GB physical storage unit
Records are organized using two key types:
Partition Key (Hash Key): Primary identifier for record distribution
Sort Key (Range Key): Optional secondary key for record organization
DynamoDB capacity is measured in two units:
Read Capacity Units (RCU)
Write Capacity Units (WCU)
Read Capacity Units (RCU):
1 RCU = 1 strongly consistent read per second for items up to 4KB
1 RCU = 2 eventually consistent reads per second for items up to 4KB
For items larger than 4KB, additional RCUs are needed (rounded up)
Write Capacity Units (WCU):
1 WCU = 1 write per second for items up to 1KB
For items larger than 1KB, additional WCUs are needed (rounded up)
By Capacity
(Total RCU / 3000) + (Total WCU / 1000)
By Size
Total Size / 10 GB
Total Partitions
Round Up for the MAX(By Capacity, By Size)
Example calculation:
Given 6000 RCU and 2000 WCU:
Given 45GB data:
Final partition count:
Partition keys are converted to hash values
Hash ranges are divided equally among partitions
With 2 partitions: 50% per partition
With 3 partitions: 33.3% per partition
Poor Design Example is using date as partition key for sensor data:
Problem: Concentrates writes on single partition for current date
Result: Underutilized capacity on other partitions
Optimized Design:
Use sensor_id as partition key
Use date as sort key
Benefit: Distributes load across partitions naturally
DynamoDB offers three scaling modes for managing table capacity:
Provision Mode is best for predictable workloads.
You specify Read and Write Capacity Units (RCUs/WCUs)
More cost-effective when traffic patterns are consistent
Allows capacity reservations for cost optimization
Can enable Auto Scaling to automatically adjust capacity
Automatically adjusts provisioned capacity
Set target utilization percentage
Define minimum and maximum capacity limits
Uses Amazon Application Auto Scaling
Works by:
Monitoring CloudWatch metrics
Triggering scaling actions when thresholds are reached
Gradually adjusting capacity within defined bounds
Note: You can switch between Provisioned and On-Demand modes once per 24 hours. Auto Scaling is a feature of Provisioned mode and can't be used with On-Demand mode.
This diagram below illustrates an AWS architecture for DynamoDB auto-scaling notification workflow. Let me break down the numbered components and their interactions:
A user or application initiates an interaction with the DynamoDB table (shown by arrow 1)
There's a direct connection from the DynamoDB table to Amazon CloudWatch (shown by arrow 2)
CloudWatch communicates with Amazon SNS (Simple Notification Service) (shown by arrow 3)
CloudWatch triggers the Application Auto Scaling service (shown by arrow 4)
The Application Auto Scaling service sends an UpdateTable command to the DynamoDB table (shown by arrow 5)
The DynamoDB table is updated with new capacity settings (shown by arrow 6)
The workflow demonstrates how AWS automatically handles scaling for DynamoDB:
CloudWatch monitors the DynamoDB table's metrics
When thresholds are reached, it triggers notifications through SNS
The Auto Scaling service adjusts the table's capacity accordingly
Changes are applied back to the DynamoDB table
This is a common pattern for implementing automatic scaling of DynamoDB resources based on actual usage patterns, helping to maintain performance while optimizing costs.
The warning symbol (⚠️) next to CloudWatch suggests that this component is responsible for monitoring and alerting on any issues or threshold breaches.
Configuration:
Set provisioned capacity limits
Define target utilization
CloudWatch monitors usage
Application Auto Scaling adjusts capacity
Limitations:
Doesn't effectively scale down with zero usage
Workarounds:
Maintain minimal request flow
Manually set max capacity to match minimum
Features:
Supports global secondary indexes
Uses target tracking for utilization
Alternative to traditional auto scaling
Advantages:
No advance capacity provisioning
Immediate scaling response
Disadvantages:
Higher cost premium
Automatically scales up/down based on actual traffic
No need to specify RCUs or WCUs
Pay-per-request pricing
Best for:
Unpredictable workloads
New applications with unknown patterns
Applications with significant traffic variations
More expensive than well-optimized provisioned capacity
In-memory caching layer
Compatible with DynamoDB API
Provides microsecond response times
Recommended for:
Applications requiring ultra-fast lookups
Read-intensive workloads
Not recommended for:
Write-intensive applications
Applications with built-in local caching
Partition Key Design:
Choose keys with high cardinality
Ensure even distribution of access patterns
Avoid temporal or sequential keys for high-volume data
Scaling Strategy:
Start with auto scaling for predictable workloads
Consider on-demand scaling for new applications
Monitor and adjust based on usage patterns
Performance Optimization:
Implement DAX for read-heavy workloads
Design key schema to prevent hot partitions
Regular monitoring of capacity utilization