You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Understanding DynamoDB's capacity modes and pricing model is essential for controlling costs and ensuring performance. This lesson covers on-demand and provisioned capacity, auto-scaling, reserved capacity, and how to estimate costs.
DynamoDB measures throughput in capacity units:
| Read Type | Size | RCUs |
|---|---|---|
| Strongly consistent | Up to 4 KB | 1 RCU |
| Eventually consistent | Up to 4 KB | 0.5 RCU |
| Transactional | Up to 4 KB | 2 RCUs |
For items larger than 4 KB, DynamoDB rounds up. For example, a 6 KB item consumes 2 RCUs for a strongly consistent read.
| Write Type | Size | WCUs |
|---|---|---|
| Standard | Up to 1 KB | 1 WCU |
| Transactional | Up to 1 KB | 2 WCUs |
For items larger than 1 KB, DynamoDB rounds up. For example, a 3 KB item consumes 3 WCUs.
DynamoDB offers two capacity modes:
Pay per request with no capacity planning:
| Feature | Description |
|---|---|
| Billing | Per read/write request |
| Scaling | Instant — handles spikes automatically |
| Provisioning | None required |
| Best for | Unpredictable workloads, new applications, spiky traffic |
aws dynamodb create-table \
--table-name MyTable \
--billing-mode PAY_PER_REQUEST \
...
You specify the number of reads and writes per second:
| Feature | Description |
|---|---|
| Billing | Per provisioned RCU/WCU per hour |
| Scaling | Manual or auto-scaling |
| Provisioning | Set RCU and WCU values |
| Best for | Predictable workloads, cost optimisation |
aws dynamodb create-table \
--table-name MyTable \
--billing-mode PROVISIONED \
--provisioned-throughput \
ReadCapacityUnits=100,WriteCapacityUnits=50 \
...
| Aspect | On-Demand | Provisioned |
|---|---|---|
| Capacity planning | None | Required |
| Cost per request | Higher | Lower |
| Scaling speed | Instant | Minutes (auto-scaling) |
| Burst handling | Automatic | Limited by provisioned capacity |
| Billing model | Pay per request | Pay per hour |
| Switching | Can switch once every 24 hours | Can switch once every 24 hours |
Auto-scaling automatically adjusts provisioned capacity based on actual traffic:
# Register the scalable target
aws application-autoscaling register-scalable-target \
--service-namespace dynamodb \
--resource-id "table/MyTable" \
--scalable-dimension "dynamodb:table:ReadCapacityUnits" \
--min-capacity 5 \
--max-capacity 1000
# Create the scaling policy
aws application-autoscaling put-scaling-policy \
--service-namespace dynamodb \
--resource-id "table/MyTable" \
--scalable-dimension "dynamodb:table:ReadCapacityUnits" \
--policy-name "ReadAutoScaling" \
--policy-type "TargetTrackingScaling" \
--target-tracking-scaling-policy-configuration '{
"TargetValue": 70.0,
"PredefinedMetricSpecification": {
"PredefinedMetricType": "DynamoDBReadCapacityUtilization"
}
}'
Tip: Auto-scaling reacts to sustained changes, not short spikes. It typically takes 1-2 minutes to scale up. For sudden bursts, DynamoDB provides burst capacity from unused capacity (up to 5 minutes of unused throughput).
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.