gpt4 book ai didi

database - 如何使用云形成 yaml 配置设置 DynamoDB 的最大预配置容量?

转载 作者:搜寻专家 更新时间:2023-10-30 19:47:26 25 4
gpt4 key购买 nike

我正在使用 yaml 配置文件创建 dynamo DB 表并设置一些配置:

ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1

这设置了所需的一致读/写的最小数量。如果可以的话,如何设置读/写的最大配置容量?

enter image description here

最佳答案

在您使用的示例中,您没有设置自动扩展中的最小预配置容量,而是设置预配置容量。

要配置自动缩放资源,您应该使用 AWS::ApplicationAutoScaling::ScalableTarget

其结构如下:

Type: "AWS::ApplicationAutoScaling::ScalableTarget"
Properties:
MaxCapacity: Integer
MinCapacity: Integer
ResourceId: String
RoleARN: String
ScalableDimension: String
ScheduledActions:
- ScheduledAction
ServiceNamespace: String

这是一个 DynamoDB 示例:

Resources:
DDBTable:
Type: "AWS::DynamoDB::Table"
Properties:
AttributeDefinitions:
-
AttributeName: "ArtistId"
AttributeType: "S"
-
AttributeName: "Concert"
AttributeType: "S"
-
AttributeName: "TicketSales"
AttributeType: "S"
KeySchema:
-
AttributeName: "ArtistId"
KeyType: "HASH"
-
AttributeName: "Concert"
KeyType: "RANGE"
GlobalSecondaryIndexes:
-
IndexName: "GSI"
KeySchema:
-
AttributeName: "TicketSales"
KeyType: "HASH"
Projection:
ProjectionType: "KEYS_ONLY"
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
WriteCapacityScalableTarget:
Type: "AWS::ApplicationAutoScaling::ScalableTarget"
Properties:
MaxCapacity: 15
MinCapacity: 5
ResourceId: !Join
- /
- - table
- !Ref DDBTable
RoleARN: !GetAtt ScalingRole.Arn
ScalableDimension: dynamodb:table:WriteCapacityUnits
ServiceNamespace: dynamodb
ScalingRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Principal:
Service:
- application-autoscaling.amazonaws.com
Action:
- "sts:AssumeRole"
Path: "/"
Policies:
-
PolicyName: "root"
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Action:
- "dynamodb:DescribeTable"
- "dynamodb:UpdateTable"
- "cloudwatch:PutMetricAlarm"
- "cloudwatch:DescribeAlarms"
- "cloudwatch:GetMetricStatistics"
- "cloudwatch:SetAlarmState"
- "cloudwatch:DeleteAlarms"
Resource: "*"
WriteScalingPolicy:
Type: "AWS::ApplicationAutoScaling::ScalingPolicy"
Properties:
PolicyName: WriteAutoScalingPolicy
PolicyType: TargetTrackingScaling
ScalingTargetId: !Ref WriteCapacityScalableTarget
TargetTrackingScalingPolicyConfiguration:
TargetValue: 50.0
ScaleInCooldown: 60
ScaleOutCooldown: 60
PredefinedMetricSpecification:
PredefinedMetricType: DynamoDBWriteCapacityUtilization

关于database - 如何使用云形成 yaml 配置设置 DynamoDB 的最大预配置容量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48210963/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com