Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB auto scaling with Cloudformation

AWS released auto scaling for DynamoDB. I would like to know how to create a Table with auto scaling via Cloudformation.

like image 832
Filipe Santana Avatar asked Jul 06 '17 20:07

Filipe Santana


People also ask

Can DynamoDB scale automatically?

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.

How do I enable auto scaling in DynamoDB?

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.

What is KeySchema in DynamoDB?

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.

How long does it take for DynamoDB to scale up?

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).


1 Answers

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
}   
like image 94
notionquest Avatar answered Sep 20 '22 15:09

notionquest