AWS released auto scaling for DynamoDB. I would like to know how to create a Table with auto scaling via Cloudformation.
If you use the AWS Management Console to create a table or a global secondary index, DynamoDB auto scaling is enabled by default. You can modify your auto scaling settings at any time. For more information, see Using the AWS Management Console with DynamoDB auto scaling.
Select Customize settings. In the Read/write capacity settings section, select Provisioned capacity mode and set Auto scaling to On for Read capacity, Write capacity, or both.
KeySchema. Specifies the attributes that make up the primary key for a table or an index. The attributes in KeySchema must also be defined in the AttributeDefinitions array. For more information, see Data Model in the Amazon DynamoDB Developer Guide.
DynamoDB auto scaling increases provisioned capacity when utilization exceeds 70 RCUs for at least two consecutive minutes. DynamoDB auto scaling decreases provisioned capacity when utilization is 20% or more below the target for 15 consecutive minutes (50 RCUs).
Here is the ClodFormation auto-scaling policy for DynamoDB table. Hope it gives you some idea about how to form the policy script.
{
"Type" : "AWS::ApplicationAutoScaling::ScalingPolicy",
"Properties" : {
"PolicyName" : "MyScalingPolicy",
"PolicyType" : "TargetTrackingScaling",
"ResourceId" : "arn:aws:dynamodb:us-east-1:123456789012:table/books_table",
"ScalableDimension" : "dynamodb:table:WriteCapacityUnits",
"ServiceNamespace" : "dynamodb",
"TargetTrackingScalingPolicyConfiguration" : {
"PredefinedMetricSpecification": {
"PredefinedMetricType": "DynamoDBWriteCapacityUtilization"
},
"ScaleOutCooldown": 60,
"ScaleInCooldown": 60,
"TargetValue": 50.0
}
}
}
References:-
CloudFormaction auto-scaling policy
AWS CLI command for auto scaling
AWS CLI Command:-
aws application-autoscaling put-scaling-policy \
--service-namespace dynamodb \
--resource-id "table/TestTable" \
--scalable-dimension "dynamodb:table:WriteCapacityUnits" \
--policy-name "MyScalingPolicy" \
--policy-type "TargetTrackingScaling" \
--target-tracking-scaling-policy-configuration file://scaling-policy.json
scaling-policy.json:-
{
"PredefinedMetricSpecification": {
"PredefinedMetricType": "DynamoDBWriteCapacityUtilization"
},
"ScaleOutCooldown": 60,
"ScaleInCooldown": 60,
"TargetValue": 50.0
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With