0
0
DynamoDBquery~5 mins

Auto-scaling configuration in DynamoDB

Choose your learning style9 modes available
Introduction

Auto-scaling helps your database adjust its capacity automatically. This keeps performance steady and saves money.

When your app has changing traffic during the day.
If you want to avoid manual changes to database capacity.
To handle sudden spikes in users without slowing down.
When you want to save costs by scaling down during low use.
To keep your database responsive without guessing traffic.
Syntax
DynamoDB
aws application-autoscaling register-scalable-target \
  --service-namespace dynamodb \
  --resource-id table/YourTableName \
  --scalable-dimension dynamodb:table:ReadCapacityUnits \
  --min-capacity 5 \
  --max-capacity 100

aws application-autoscaling put-scaling-policy \
  --service-namespace dynamodb \
  --resource-id table/YourTableName \
  --scalable-dimension dynamodb:table:ReadCapacityUnits \
  --policy-name MyScalingPolicy \
  --policy-type TargetTrackingScaling \
  --target-tracking-scaling-policy-configuration file://config.json

The first command sets the min and max capacity for your table.

The second command creates a policy to adjust capacity based on usage.

Examples
Registers write capacity scaling for the 'Orders' table with min 10 and max 200 units.
DynamoDB
aws application-autoscaling register-scalable-target \
  --service-namespace dynamodb \
  --resource-id table/Orders \
  --scalable-dimension dynamodb:table:WriteCapacityUnits \
  --min-capacity 10 \
  --max-capacity 200
This JSON config sets the target usage at 70% for write capacity with cooldown times.
DynamoDB
{
  "TargetValue": 70.0,
  "PredefinedMetricSpecification": {
    "PredefinedMetricType": "DynamoDBWriteCapacityUtilization"
  },
  "ScaleOutCooldown": 60,
  "ScaleInCooldown": 60
}
Sample Program

This example sets auto-scaling for the 'Books' table read capacity. It keeps usage near 70% by scaling between 5 and 50 units.

DynamoDB
aws application-autoscaling register-scalable-target \
  --service-namespace dynamodb \
  --resource-id table/Books \
  --scalable-dimension dynamodb:table:ReadCapacityUnits \
  --min-capacity 5 \
  --max-capacity 50

aws application-autoscaling put-scaling-policy \
  --service-namespace dynamodb \
  --resource-id table/Books \
  --scalable-dimension dynamodb:table:ReadCapacityUnits \
  --policy-name ReadCapacityScalingPolicy \
  --policy-type TargetTrackingScaling \
  --target-tracking-scaling-policy-configuration '{
    "TargetValue": 70.0,
    "PredefinedMetricSpecification": {
      "PredefinedMetricType": "DynamoDBReadCapacityUtilization"
    },
    "ScaleOutCooldown": 60,
    "ScaleInCooldown": 60
  }'
OutputSuccess
Important Notes

Auto-scaling only works if your table uses provisioned capacity mode.

Cooldown times help avoid too many scaling actions in a short time.

Monitor your scaling policies to make sure they fit your app's needs.

Summary

Auto-scaling adjusts database capacity automatically based on usage.

You set minimum and maximum capacity limits to control scaling.

Target tracking policies keep usage near a set percentage for smooth performance.