Your team creates a Docker image for a new web application and deploys it in an AWS ECS cluster.
You want to automatically increase or decrease the desired count of ECS tasks in the ECS service based on the average CPU utilization.
The number of ECS tasks should be adjusted between 3 and 6 and the target value of CPU utilization should be 70
How would you configure this?
Click on the arrows to vote for the correct answer
A. B. C. D.Correct Answer - D.
Option A is incorrect because the auto scaling should be configured in the ECS service.
Although you can configure a scaling policy in the Auto Scaling group, the scaling policy cannot adjust the number of ECS tasks.
Option B is incorrect because in the ECS service, you should configure a target tracking scaling policy instead of step scaling policies.
The question mentioned that the value of CPU utilization should be targeted as 70 so that a target tracking scaling policy is needed.
Option C is incorrect because the target tracking scaling policy should be configured in the ECS service instead of the ECS task definition.
Option D is CORRECT because you can add a scaling policy for the ECS service.
The number of ECS tasks will automatically scale based on the target value of the ECSServiceAverageCPUUtilization metric.
Reference:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-autoscaling-targettracking.html.The correct answer to this question is D. Configure the auto scaling in the ECS service by adding a target tracking scaling policy based on the ECSServiceAverageCPUUtilization metric.
Explanation:
ECS (Elastic Container Service) is a fully managed container orchestration service provided by AWS. With ECS, you can deploy, manage, and scale Docker containers on a cluster of EC2 instances. ECS allows you to specify the number of tasks (containers) that should be running in a service.
Auto Scaling is a feature provided by AWS that allows you to automatically adjust the number of EC2 instances, ECS tasks, or other resources in response to changes in demand. Auto Scaling can be based on different metrics, such as CPU utilization, memory utilization, network traffic, etc.
To automatically increase or decrease the number of ECS tasks in an ECS service based on the average CPU utilization, we need to configure auto scaling in the ECS service.
Option A is incorrect because an Auto Scaling group is used to manage EC2 instances, not ECS tasks. While we can use EC2 Auto Scaling to manage the EC2 instances in an ECS cluster, it does not provide automatic scaling for ECS tasks.
Option B is incorrect because the Auto Scaling tab in the ECS service console is used to configure scaling policies for the EC2 instances in the ECS cluster, not for the ECS tasks in the ECS service.
Option C is incorrect because target tracking auto scaling is used to adjust the desired capacity of an Auto Scaling group based on a target value for a specific metric, such as CPU utilization. While we can use target tracking auto scaling to adjust the number of ECS tasks in an ECS service, it is not configured in the task definition. Also, the ECSTaskAverageCPUUtilization metric is not available in CloudWatch.
Therefore, the correct option is D. We need to configure auto scaling in the ECS service by adding a target tracking scaling policy based on the ECSServiceAverageCPUUtilization metric. This can be done by following these steps:
Once the scaling policy is created, ECS will automatically adjust the desired count of ECS tasks based on the average CPU utilization, keeping it between 3 and 6.