0
votes

I'm trying to figure out if I can write an auto scaling rule for my ec2 auto scaling group that causes it to add more instances when ECS is out of container instances to run on. The idea being this auto scaling group would be shared by multiple ECS services in a cluster.

I have my ASG setup for the target group the ECS service is configured for.

Base case:

  1. No instances started by auto scaling group, min = 0, max = 10
  2. An ECS Service is created in the default cluster, task is configured to be launched but no instances available.
  3. Auto scaling group detects need and adds an instance
  4. Once instance is up, service runs task on available instance

Additional Case:

  1. Another service is added to the default cluster
  2. Only one instance available (added from base case)
  3. Not enough resources on instance to run additional service
  4. Auto Scaling Group adds new instance which connects to default cluster
  5. Once instance is up, service runs on newly available isntance.

Scale Down Case:

  1. Service is deleted in ECS
  2. Instance memory/usage drops below threshold
  3. Auto Scaling Group stops instance

Has anyone done this? Is it possible without writing custom code to monitor ECS?

I feel like Fargate is kind of the answer to this but I'd like to know if it's possible with Auto Scaling Groups since I can't use Fargate just yet.

1

1 Answers

0
votes

Hi you need to use a cloudwatch alarm based on CPU reservation and/or Memory reservation Metrics

I hope this helps