AutoScalr has always supported EC2 Container Service (ECS) deployments due to modular architecture of AutoScalr that extends the Amazon Web Services (AWS) auto scaling group. So anywhere an auto scaling group is used, including ECS, AutoScalr can be used. But as of today, AutoScalr is also “ECS and container aware” and will perform Docker container level resource optimizations to both scale quicker under load changes and optimize costs more efficiently than before.
One of the challenges of auto-scaling in a containerized environment is there are two distinct types of auto-scaling required that have to work together:
- Container/task scaling: auto-scaling the number of containers/tasks of a service, and
- Capacity scaling: auto-scaling the number of EC2 instances that provide the nodes for the containers to run on
ECS has built in support for Container scaling. You can set scale up and scale down alarms based upon service level metrics to add/remove containers. Capacity scaling is typically done by the auto-scaling group tied to the ECS cluster using aggregate metrics exposed by the cluster such as CPU utilization. This is conceptually simple but there are a number of edge cases to think through and make sure your auto-scaling is configured to handle correctly. First, which of the 4 ECS cluster metrics do you select to scale on:
- CPU Utilization
- CPU Reservation
- Memory Utilization
- Memory Reservation
If you pick wrong, your cluster may get stuck and not scale up at all for some scenarios, or scale up too soon and be wastefully spending EC2 resources. In addition there is the scaling time frame mismatch to keep in mind: Containers scale very quickly compared to EC2 instances, so you need to make sure you keep a little spare capacity around to handle containers scaling while you wait for an EC2 instance to startup.
AutoScalr now solves the capacity scaling portion of auto-scaling on ECS for you, letting you focus solely on the container scaling of your service.
It does this by looking at more than just the aggregate cluster metrics to make scaling decisions. It also analyzes the number and type of tasks that are running, the desired number of tasks each service has, and the CPU and memory requirements of each desired task based upon the task definitions, all automatically. The end result is AutoScalr knows exactly how much capacity is required, both CPU and memory, and can scale up quicker, and scale down faster to make the cluster not only more cost effective but also able to handle traffic spikes quicker.