ECS autoscaling with an ASG capacity provider

0

We have configured an ECS cluster with an ASG capacity provider and CPU auto-scaling. Auto-scaling is trying to deploy more containers, but to do that it needs to start a new instance in the ASG

service X was unable to place a task because no container instance met all of its requirements. 
The closest matching container-instance X has insufficient CPU units available. For more information, see the Troubleshooting section of the Amazon ECS Developer Guide

Is this expected behavior? I was expected ECS autoscaling to try and launch instances in the cluster on its own

Thanks, Fouad

1 Answer
1

Yes, this is expected behavior when using an auto scaling group (ASG) with an ECS cluster.

The ECS auto scaling is responsible for scaling the tasks/containers based on metrics like CPU and memory utilization. However, it does not automatically launch new EC2 instances in the ASG.

The ASG is responsible for launching and terminating EC2 instances to maintain the desired capacity. But it does not know about ECS task placement requirements.

So when ECS wants to place more tasks, it first needs the ASG to launch new instances to add capacity to the cluster. The ASG won't do this on its own until its own scaling metrics (CPU, network etc.) trigger.

To solve this:

  • Configure ASG scale-out policies based on ECS metrics like pending tasks. This will trigger instance launches when ECS needs more capacity.

  • Use EC2 autoscaling directly instead of an ASG. ECS can then launch instances on its own when it needs more capacity.

  • Pre-warm your ASG to have spare capacity for ECS to scale out without waiting for new instances.

So in summary, the current behavior is expected due to the separation between ECS (scales tasks) and ASG (scales instances). You need to align their scaling metrics for a smoother experience.

AWS
Saad
answered 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions