EC2 Auto Scaling Groups

Auto Scaling is a feature of EC2 that can automatically adjust the capacity of your system. It does this by creating and terminating EC2 instances.

In particular, which the load on your system increases, new instances are created to share the load. When that load decreases, the excess instances are terminated to save money.

An Auto Scaling Group (ASG) is used to configure this feature. In the ASG, you specify three main things:

  1. The minimum and maximum number of EC2 instances that should be running at any time.
  2. The Launch Configuration to use when creating new instances.
  3. The Elastic Load Balancer that new instances should be registered with.

As you can see, Auto Scaling Groups really tie the EC2 features together.

What should I do?

  1. Create a new Auto Scaling Group.
  2. Configure it with an existing Launch Configuration.
  3. Select all default subnets.
  4. In Advanced Details, check "Receive traffic from Elastic Load Balancer(s)" and select your Elastic Load Balancer.
  5. Select "Use scaling policies to adjust the capacity of this group", with the following policies:
    • Scale between 1 and 3 instances (or however many you're comfortable with)
    • Increase group size: Add new alarm (as below), and take the action "Add 30 percent of group" Configuration of CloudWatch alarm triggering an auto scale out
    • Decrease group size: Add new alarm (as below), and take the action "Remove 2 instances" Configuration of CloudWatch alarm triggering an auto scale in
  6. Ignore notifications and tags.
  7. Review and create the ASG.

Finally, your EC2 service is capable of creating its own instances as needed!

What's Next?

Thanks to the AMI and User Data added in the Launch Configuration, each instance will automatically join an ECS cluster. While EC2 manages the infrastructure your applications run on, ECS manages what applications are running. This is a powerful separation of concerns.

This wraps up our configuration of EC2, so let's move right along to setting up ECS!

See Also