LoginSignup
0
0

More than 3 years have passed since last update.

Fargateのキャパシティープロバイダー戦略

Last updated at Posted at 2020-12-01

Fargateでもスポットインスタンスを使う

fargateでオートスケールの際に「費用削減したい」との要望があり、スポットインスタンスを使うことにした。

キャパシティプロバイダーを設定する

タイプ base weight
FARGATE_SPOT 1 5
FARGATE 2 2

この場合は、最初にFARGATEが2台、FARGATE_SPOTが1台起動する。AutoScaleによって増える場合は、
FARGATE:FARGATE_SPOT=2:5の割合で増える。

タイプ スタート時の台数 AutoScaleで7台構成になった場合
FARGATE_SPOT 1台 5台
FARGATE 2台 2台

設定を行う。

aws ecs put-cluster-capacity-providers \
     --cluster [クラスター名] \
     --capacity-providers FARGATE FARGATE_SPOT \
     --default-capacity-provider-strategy capacityProvider=FARGATE_SPOT,weight=5,base=1 capacityProvider=FARGATE,weight=1,base=2

サービスへの登録

$ aws ecs create-service \
--cluster web-cluster \
--service-name web-prod \
--launch-type "FARGATE" \
--capacity-provider-strategy capacityProvider=FARGATE,weight=2,base=2 capacityProvider=FARGATE_SPOT,weight=5,base=1 \
--task-definition gservice-prod \
--network-configuration "awsvpcConfiguration={subnets=[subnet-xxxxx,subnet-yyyyy],securityGroups=[sg-zzzzzz],assignPublicIp=DISABLED}" \
--deployment-configuration maximumPercent=200,minimumHealthyPercent=100 \
--load-balancer targetGroupArn=arn:aws:elasticloadbalancing:ap-northeast-1:xxxxxxxxxxxxx,containerName=gservice,containerPort=9000 \
--desired-count 1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0