I have a cluster, lets say my-cluster. It has 2 services running. Lets call them my-services. Each services has 1 tasks running. my-task1 and my-task2.
The EC2 instances are launched by an autoscaling group which launches 2 EC2 instances. I am using an application load balancer.
When I created the service I selected AZ-balance-spread which is described: "This template will spread tasks across availability zones and within the availability zone spread tasks across instances. Learn more. Strategy: spread(attribute:ecs.availability-zone), spread(instanceId)"
My EC2 instances are on different Availability Zones. But when I click on my-cluster and select the ECS-instances tab, I see the 2 tasks running both on 1 container instance. The other container instance says 0 tasks running.
I was expecting 2 container instances, and each having 1 task running.
My question is, if I selected AZ-balance-spread shouldn't these tasks be spread between the 2 EC2 instances which are on separate AZ's?
I want to set it up so all tasks are spread out between AZ's so if an instance goes down the other task on the other instance in the other AZ is still up. But I can't seem to figure out how to do this. That being said if I create 4 tasks, it does spread them between the two instances. 2 tasks for one and 2 tasks for another. But when I just have 2 tasks, it will put them all in one EC2 instance.
Your help is much appreciated in solving this mystery!
Thanks!