[英]How can dynamodb secondary indexes be autoscaled with Cloudformation templates?
我已经看到了向具有cloudformation的表添加自动缩放的示例,但除了dynamodb控制台中的“将相同设置应用于全局二级索引”复选框之外,我没有看到使用cloudformation模板定义此方法的方法。
It is possible to define the secondary index as an autoscaling target. 可以将辅助索引定义为自动缩放目标。
You need just to specify the index as the resourceId
using /index/**YOUR_INDEX_NAME**
as a suffix and using dynamodb:index:WriteCapacityUnits
and dynamodb:index:ReadCapacityUnits
as ScalableDimension
. 您只需要将索引指定为
resourceId
使用/index/**YOUR_INDEX_NAME**
作为后缀并使用dynamodb:index:WriteCapacityUnits
和dynamodb:index:ReadCapacityUnits
作为ScalableDimension
。
Eg 例如
SecIndexWriteCapacity:
Type: AWS::ApplicationAutoScaling::ScalableTarget
Properties:
MaxCapacity: 1000
MinCapacity: 15
ResourceId: !Sub "table/${MY_MAIN_TABLE}/index/${MY_SECONDARY_INDEX_NAME}"
RoleARN: !GetAtt ScalingRole.Arn
ScalableDimension: dynamodb:index:WriteCapacityUnits
ServiceNamespace: dynamodb
SecIndexReadCapacity:
Type: AWS::ApplicationAutoScaling::ScalableTarget
Properties:
MaxCapacity: 1000
MinCapacity: 15
ResourceId: !Sub "table/${MY_MAIN_TABLE}/index/MY_SECONDARY_INDEX_NAME"
RoleARN: !GetAtt ScalingRole.Arn
ScalableDimension: dynamodb:index:ReadCapacityUnits
ServiceNamespace: dynamodb
SecIndexWriteScalingPolicy:
Type: AWS::ApplicationAutoScaling::ScalingPolicy
Properties:
PolicyName: SecIndexWriteScalingPolicy
PolicyType: TargetTrackingScaling
ScalingTargetId: !Ref SecIndexWriteCapacity
TargetTrackingScalingPolicyConfiguration:
TargetValue: 50.0
ScaleInCooldown: 30
ScaleOutCooldown: 1
PredefinedMetricSpecification:
PredefinedMetricType: DynamoDBWriteCapacityUtilization
SecIndexReadScalingPolicy:
Type: AWS::ApplicationAutoScaling::ScalingPolicy
Properties:
PolicyName: SecIndexReadScalingPolicy
PolicyType: TargetTrackingScaling
ScalingTargetId: !Ref SecIndexReadCapacity
TargetTrackingScalingPolicyConfiguration:
TargetValue: 50.0
ScaleInCooldown: 30
ScaleOutCooldown: 0
PredefinedMetricSpecification:
PredefinedMetricType: DynamoDBReadCapacityUtilization
See also https://aws.amazon.com/blogs/database/how-to-use-aws-cloudformation-to-configure-auto-scaling-for-amazon-dynamodb-tables-and-indexes/ 另见https://aws.amazon.com/blogs/database/how-to-use-aws-cloudformation-to-configure-auto-scaling-for-amazon-dynamodb-tables-and-indexes/
Actually it is possible. 实际上这是可能的。
Follow the official AWS example for the DynamoDB/CloudFormation , but for each GSI you would need to create a separate ScalableTarget and a Scalable Policy. 按照DynamoDB / CloudFormation的官方AWS示例进行操作 ,但是对于每个GSI,您需要创建单独的ScalableTarget和可扩展的策略。 In the ScalableTarget properties use
table/my-table/index/my-table-index
notation for the ResourceId. 在ScalableTarget属性中,对ResourceId使用
table/my-table/index/my-table-index
表示法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.