How to Scale Out an AWS ECS Service


When you create the Amazon ECS service, it includes three Amazon ECS task replicas. You can see this by using the describe-services command, which returns three. Use the update-service command to scale the service to five tasks. Re-run the describe-services command to see the updated five.

Step 1 – Query the desired count

aws ecs describe-services \
--cluster fargate-getting-started \
--services nginx-service \
--query 'services[0].desiredCount'

Output: 3

Step 2 – Set the new desired count

aws ecs update-service \
--cluster fargate-getting-started \
--service nginx-service \
--desired-count 5

This will now update the service to have a desired count of 5.

Step 3 – Query the updated desired count

aws ecs describe-services \
--cluster fargate-getting-started \
--services nginx-service \
--query 'services[0].desiredCount'

Output: 5