- Newest
- Most votes
- Most comments
The issue you're experiencing is related to how ECS manages task placement and capacity during deployments. Even though you've configured your deployment settings with 100% minimum and 200% maximum running tasks, which should theoretically allow for two tasks to run simultaneously during deployment, the auto scaling group isn't scaling up as expected.
Here are the likely reasons and solutions:
-
Capacity Provider Reservation Metric: The CapacityProviderReservation metric you're using tracks the percentage of resources that are being used by ECS tasks. During a deployment, ECS first tries to place the new task on existing instances before triggering a scale-out event. If your existing instance doesn't have enough capacity to run both tasks simultaneously (due to CPU, memory, or port conflicts), the new task will remain in a pending state, but this might not immediately trigger scaling.
-
Port Conflicts: If your container is using host networking mode and binding to specific ports, the new task can't start because the required port is already in use by the existing task. This is a common issue when using the 'host' networking mode.
-
Warm-up Time: Your configuration shows a 300-second (5-minute) warm-up time for new instances. This means that even if a scale-out event is triggered, there will be a delay before the new instance is considered ready.
To address these issues:
-
Consider using awsvpc network mode instead of host networking to avoid port conflicts. This allows multiple tasks to run on the same instance without port conflicts.
-
Adjust your capacity provider strategy to be more aggressive about scaling out. You might need to lower the target value from 100% to something like 70-80% to trigger scale-out events earlier.
-
Review your task placement strategies and constraints to ensure they're not preventing the new task from starting.
-
Enable managed instance draining in your capacity provider settings. This allows ECS to gracefully remove tasks from an instance that's being scaled in.
-
Implement a rolling update strategy with appropriate minimum and maximum percentages to gradually replace old tasks with new ones.
By implementing these changes, you should be able to create a more efficient deployment process that scales out when needed for deployments and scales back in when the extra capacity is no longer required.
Sources
Running Update Service shows a pending task, but never shuts down the existing task so a new deployment runs | AWS re:Post
ECS Task Deployment Doesn't Reserve More Capacity | AWS re:Post
answered a year ago
Hello.
What is your ECS task placement strategy configured?
I thought it might be possible that "binpack" was configured to minimize EC2 instances.
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-placement-strategies.html
I have also experienced situations in the past where AutoScaling did not work properly because EC2 could not be launched due to quota restrictions on EC2 instance types.
So, please check if any of the above is happening.
I have maybe 8 instances in my account and only 2 or 3 of this specific type so I doubt I'm hitting that. There is no constraints on placement strategy. This is like the simplest ECS deployment possible. But what I want is when I deploy a new task my Auto Scaling Group spins up a new EC2 instance for the task to get placed on that, and when it's done decommission and stop the old instance. I was looking at dynamic scaling policies and scaling policies in ECS to do this, but from how those things are structured it's clear AWS has never thought about doing what I'm trying to do using those mechanisms. And I've never seen anyone else talk about how to set this up. But this HAS to be a common use case. Otherwise I have no idea how people update their deployed contains.
Relevant content
asked 4 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 months ago

This isn't super helpful. This answer is clearly based on the other answer from an expert which mostly says the exact same information in another post. But it's not very deep or insightful about this problem specifically. It's general information that leaves the reader to figure the technical side of things out. It's mostly double check this or that with very generic high level ideas. It's not really looking at what I'm trying to do and what isn't happening. Besides I've done most of these ideas already.