Currently I have a ECS cluster running a service that is running a single task per container instance, each task takes nearly all the container instance´s resources. I'm wondering if there´s some way, perhaps by setting up the Number of tasks, Minimum healthy percent, Maximum percent on the service as well as a capacity provider to have it where once a new task version is to be deployed a new container instance is spinned up and once that is ready the old container instance is removed.

So using 2 container instances during the deploy, the old one and the one being spun up for the new task definition and in the end removing the old container instance, just leaving the 1 container instance running once the deploy is complete.

2 Answers 2


If you use ECS cluster auto scaling, the cluster will automatically add new instances as needed to place tasks during a deployment. Or, you could use Fargate and not worry about EC2 instance scaling at all.

  • 1
    Can you add more details to your answer ? I added cluster auto scaling but instances are not created on deployment. Jul 21, 2021 at 9:59

This is usually called blue / green deployment and is described here. Remember to give the old container some time for connections to drain so all traffic goes to the new container.

In short, ECS can do this for you.

Amazon Elastic Container Service (ECS) performs rolling updates when you update an existing Amazon ECS service. A rolling update involves replacing the current running version of the container with the latest version. The number of containers Amazon ECS adds or removes from service during a rolling update is controlled by adjusting the minimum and maximum number of healthy tasks allowed during service deployments.

When you update your service’s task definition with the latest version of your container image, Amazon ECS automatically starts replacing the old version of your container with the latest version. During a deployment, Amazon ECS drains connections from the current running version and registers your new containers with the Application Load Balancer as they come online.

  • Right, but the issue here is I have 1 task in one container instance (EC2) that's consuming enough resources that a new EC2 instance would be required to run the task, they both won't fit in the same EC2 container instance. So I tried setting up a Auto scaling group but didn't get it to behave the way I wanted. Jun 22, 2020 at 18:43
  • I've not done much with ECS, but my approach would be to use a new host EC2 instance. What resource doesn't the EC2 server have? If it's CPU that would probably be ok, the new container will use minimal until it serves traffic. Disk is easy to expand. Memory could be problematic, you could add virtual memory. Really though if this is an important service you should probably have two smaller instance behind a load balancer with auto scaling set up, to provide reliability and scalability.
    – Tim
    Jun 22, 2020 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.