{Aurora}Aurora レプリカでの Amazon Aurora Auto Scaling の使用

Aurora DB クラスタで Aurora Auto Scaling を使用する前に、
まず、プライマリインスタンスと少なくとも 1 つの Aurora レプリカで Aurora DB クラスタを作成する必要があります。

 

 

-- スケーリングポリシーの追加

---- ターゲットクラスタの登録

aws application-autoscaling register-scalable-target \
--service-namespace rds \
--resource-id cluster:cluster01 \
--scalable-dimension rds:cluster:ReadReplicaCount \
--min-capacity 1 \
--max-capacity 2


---- Aurora DB クラスタへのスケーリングポリシーの適用

vim a.json

{
"TargetValue": 40.0,
"PredefinedMetricSpecification":
{
"PredefinedMetricType": "RDSReaderAverageCPUUtilization"
},
"ScaleInCooldown": 600,
"ScaleOutCooldown": 300
}

aws application-autoscaling put-scaling-policy \
--policy-name policy01 \
--policy-type TargetTrackingScaling \
--resource-id cluster:cluster01 \
--service-namespace rds \
--scalable-dimension rds:cluster:ReadReplicaCount \
--target-tracking-scaling-policy-configuration file://a.json

-- ターゲットクラスタの登録解除

aws application-autoscaling deregister-scalable-target \
--service-namespace rds \
--resource-id cluster:cluster01 \
--scalable-dimension rds:cluster:ReadReplicaCount

-- ターゲットクラスタ一覧
aws application-autoscaling describe-scalable-targets --service-namespace rds

-- スケーリングポリシーの削除

aws application-autoscaling delete-scaling-policy \
--policy-name policy01 \
--resource-id cluster:cluster01 \
--service-namespace rds \
--scalable-dimension rds:cluster:ReadReplicaCount


-- スケーリングポリシー一覧
aws application-autoscaling describe-scaling-policies --service-namespace rds

 

-- スケーリングポリシーの追加

---- ターゲットクラスタの登録

aws application-autoscaling register-scalable-target \
--service-namespace rds \
--resource-id cluster:cluster02 \
--scalable-dimension rds:cluster:ReadReplicaCount \
--min-capacity 1 \
--max-capacity 2


---- Aurora DB クラスタへのスケーリングポリシーの適用

vim a.json

{
"TargetValue": 3,
"PredefinedMetricSpecification":
{
"PredefinedMetricType": "RDSReaderAverageDatabaseConnections"
},
"ScaleInCooldown": 20,
"ScaleOutCooldown": 20
}

aws application-autoscaling put-scaling-policy \
--policy-name policy01 \
--policy-type TargetTrackingScaling \
--resource-id cluster:cluster02 \
--service-namespace rds \
--scalable-dimension rds:cluster:ReadReplicaCount \
--target-tracking-scaling-policy-configuration file://a.json


-- ターゲットクラスタの登録解除

aws application-autoscaling deregister-scalable-target \
--service-namespace rds \
--resource-id cluster:cluster02 \
--scalable-dimension rds:cluster:ReadReplicaCount

-- ターゲットクラスタ一覧
aws application-autoscaling describe-scalable-targets --service-namespace rds


-- スケーリングポリシーの削除

aws application-autoscaling delete-scaling-policy \
--policy-name policy01 \
--resource-id cluster:cluster02 \
--service-namespace rds \
--scalable-dimension rds:cluster:ReadReplicaCount


-- スケーリングポリシー一覧
aws application-autoscaling describe-scaling-policies --service-namespace rds

 

★スケールアウトは確認できたが、なぜかスケールインしなかった