roy
roy

Reputation: 605

ECS Service auto scaling and auto scaling group

I've decided to start playing with AWS ECS service, and created cluster and one service my issue is that I want to connect it to the AWS auto scaling group. I have followed the following guide.

The guide works, my issue is that its a total waste of money.

The guide says that I need to add machine when the total amount of CPU units that my services reserve is above 75, but in reality my services always reserve 100% because I don't want waste money, also its pretty useless to put 3 nodejs tasks on 2 cpu machine, there is no hard-limit anyway.

I am breaking my head on it for few days now, I have no idea how to make them work together properly

EDIT: Currently this is what happens:

  1. CPU getting above 75%, Service scaling is created 2 new tasks on the same server, which means that now I have 1 instance with 4 tasks

  2. Instance reservation is now 100%, Auto Scaling Group is creating new instance

  3. Once the new instance is created, Service Scaling is removing 2 tasks from the old instance and adding 2 new tasks to the new instance

Its just me or this whole process looks like waste of time? is this how it really should be or (probably) i done something wrong?

Upvotes: 2

Views: 2185

Answers (2)

roy
roy

Reputation: 605

Eventually, I figured, what I want to do is not possible. It is not possible to create a resource-optimized cluster with ECS like in Kubernetes. (unless of course if you write some magic with lambda)

Service auto-scaling and auto-scaling groups don't work together, you can, however, make it work perfectly with fargate but its expansive, the main issue is that you don't have a trigger to cluster reservation above 100%

Upvotes: 1

ThomasVdBerge
ThomasVdBerge

Reputation: 8140

I think you are missing a few insights.

For ECS autoscaling to work properly you also have to set up scaling on a ECS Service level.

Then, the scaling flow would look like this:

  1. ECS Service is reaching 100% used CPU and has 100% reserved CPU
  2. ECS Service scales by starting an additional task, making the reserved CPU total at 200%
  3. Auto scaling group sees there is more Reserved capacity than available capacity and launches a new machine.

In addition, you can perfectly run multiple nodejes tasks on a 2 CPU machine. Especially in a micro service environment, these nodejs services can be quite small (128 CPU for example) and still run perfectly fine all together on the same host machine.

Upvotes: 1

Related Questions