Elastic Container Service scaling

I’m setting up a service in ECS / Fargate which serves an API and was wondering what scaling policy would be recommended. Can anyone offer advice or share their experience?

Hi! I actually gave a talk about this at the recent AWS Container Day. You can find a video, and presentation + transcript on my blog: https://nathanpeck.com/amazon-ecs-scaling-best-practices/

Here are some basic tips that I can give you in a Reddit comment though:

- Do load testing to determine the correct vertical size for your containers

- Use Application Auto Scaling with ECS to scale based on the resource dimension that your container runs out of first during the load test (it is almost always CPU).

- Target tracking scaling is the easiest way to scale: just give it a target CPU utilization number of say 80% and it will scale out horizontally if the utilization is getting higher than your target number, and it will scale in if the utilization is getting under your target number.

This is exactly what we do.

  • Load test with K6 to see when the containers start maxing out (also stresses your app in more ways than just your tasks, if using a sql db)
  • Watch and set target tracking. For node based apps we see more memory usage, but mainly CPU target tracking is what we use.
  • Rinse and repeat until your target is set correctly.

Load testing is incredibly important to identify when and how your app breaks. Without load testing and scaling testing, most of our apps would have certainly failed under load in the first run, so make sure you load test your apps, even if it is a simple test!

Haha I was coming here to link this article!

And seriously, Target tracking is the best option for most cases.