0
votes

Now I'm architecting AWS ECS infrastructure.

To auto scale in/out, I used auto scailing.

My system is running on AWS ECS(to deploy docker-compose)

Assume that we have 1 cluster, 1 service with 2 ec2 instance.

I defined scailing policy via CloudWatch if cpu utilization up to 50%.

To autoscailing, we have to apply our policy to ecs service and autoscailing group.

When attach cloudwatch policy to ecs service, it will automatically increase task definition count if cpu utilization up to 50%.

When attach cloudwatch policy to autoscailing group, it will automatically increase ec2 instance count if cpu utilization up to 50%.

After tested it, everything works fine.

But in my service event logs, errors appear like this.

service v1 was unable to place a task because no container instance met all of its requirements. The closest matching container-instance 8bdf994d-9f73-42ec-8299-04b0c5e7fdd3 has insufficient memory available.

I think it occured because of service scailing is start before ec2 instance scailing. (Because service scailing(scale in/out task definition) need to ec2 instance to run it)

But it works fine. Maybe it retry automatically about several times. (I'm not sure)

I wonder that, it is normal configuration on AWS ECS autoscailing?

Or, any missing point in my flow?

Thanks.

1

1 Answers

0
votes

ECS can only schedule a service if a container instance is available that matches the containers cpu/memory requirements. Ensure you have this space available to guarantee smooth auto-scaling.

The ec2-asg scaling should happen before service auto-scaling to ensure container instance is available for task scheduler.