Amazon recently announced it is bringing automatic scaling to its Amazon ECS service. This allows Amazon ECS services to scale out, or scale in, automatically. Scale events are the result of Amazon CloudWatch alarms being triggered when threshold-based metrics exceed, or fall below, expected values.
Amazon ECS, also known as EC2 Container Service, is a management service that supports Docker containers on Amazon EC2 clusters. Amazon already supports auto scaling for EC2 clusters, but auto scaling container services, that run on EC2 clusters, was previously not supported.
Amazon Cloud Watch metrics drive the behavior of auto scaling events. Amazon Cloud Watch metrics include CPU utilization, data transfer or disk usage. Developers also have the ability to publish their own custom metrics to CloudWatch through a put-metric-data AWS Command or PutMetricData Query API.
An example of when you may use auto scaling includes a web service that has been deployed and is experiencing CPU pressure. In this scenario, you want to scale those container(s) out. Once, CPU pressure has returned to normal alerts, developers can configure scale in events to reduce the number of containers, and subsequently compute costs.
The following image illustrates how both scale in and scale out events are configured at both container and cluster tiers using the AWS Management Console. In both scenarios, scale events are triggered through CPU utilization levels.
Image Source: https://aws.amazon.com/blogs/compute/automatic-scaling-with-amazon-ecs/
Using Multi-AZ (Availability Zone) EC2 clusters and Elastic Load Balancers, customers can scale both EC2 clusters and EC2 Container Services across Availability Zones to provide additional fault tolerance. Mayank Thakkar, enterprise solutions architect at Amazon Web Services, explains the process in setting auto scaling up: “The process to create services that scale automatically is supported by the ECS console, CLI, and SDK. You choose the desired, minimum and maximum number of tasks, create one or more scaling policies, and Service Auto Scaling handles the rest. The service scheduler is also Availability Zone–aware, so you don’t have to worry about distributing your ECS tasks across multiple zones.”
Thakkar cautions that scaling EC2 clusters may take longer than containers, but suggests the following strategy to mitigate delays: “You may set the cluster scaling policies in such a way so that you can have some additional cluster capacity in reserve. This will help your ECS service scale up faster, but at the same time, depending on your demand, keep some EC2 instances underutilized.”
Amazon is not the only public cloud vendor to provide auto scaling of their container service. Microsoft Azure also provides this functionality in the form of Azure Virtual Machine Scale Sets (VMSS). Microsoft depends upon Azure Insights Autoscale to provide auto scale functionality without pre-provisioning VMs. Azure VMSS can not only be used with containers, but also with big compute and big data workloads. Azure VMSS is typically deployed using ARM templates, but can also be created using REST API, Powershell or Azure CLI.