arminc / terraform-ecs

AWS ECS terraform module
MIT License
804 stars 374 forks source link

Handling ECS host autoscaling policies #14

Open Puneeth-n opened 6 years ago

Puneeth-n commented 6 years ago

Good work on this module.

I had a question. How do you handle autoscaling of ECS hosts?

arminc commented 6 years ago

Thank you.

I don't have any code to show you because currently I can predict our load and don't need autoscale. But I did have a look in to it. You have different options, depending on how fancy or fast you need to be able to scale up or down.

Assuming you don't need to scale up/down very often, let's say once a month. I wouldn't make anything fancy but create a trigger on CPU or Memory usage and when that exceeds the threshold manually scale your EC2 and your containers.

If you need to scale your containers up/down constantly then AWS already can do that. As you can see here https://aws.amazon.com/blogs/compute/automatic-scaling-with-amazon-ecs/ You can provide scaling options for the EC2 instances as well as your services, based on CPU. Instead of using the CPU metric you could use your own metric like: (average processing time above X, more than X amount of messages in queue, etc...)

Maybe @nathanpeck has some tips as well?

Hope this helps.