New – EC2 Auto Scaling Groups With Multiple Instance Types & Purchase Options
Earlier this year I told you about EC2 Fleet, an AWS building block that makes it easy for you to create fleets that are built from a combination of EC2 On-Demand, Reserved, and Spot Instances that span multiple EC2 instance types. In that post I showed you how to create a fleet and walked through an example that created a genomics processing pipeline that used a mix of M4 and M5 instances. I also dropped a hint to let you know that we were working on integrating EC2 Fleet with Auto Scaling and other AWS services.
Auto Scaling Across Multiple Instance Types & Purchase Options
Today I am happy to let you know that you can now create Auto Scaling Groups that grow and shrink in response to changing conditions, while also making use of the most economical combination of EC2 instance types and pricing models. You have full control of the instance types that will be used to build your group, along with the ability to control the mix of On-Demand and Spot. You can also update your existing Auto Scaling Groups to take advantage of this new feature.
The Auto Scaling Groups that you create are optimized anew each time a scale-out or scale-in event takes place, always seeking the lowest overall cost while meeting the other requirements set by your configuration. You can modify the configuration as newer instance types become available, allowing you to create a group that evolves in step with EC2.
Creating an Auto Scaling Group
I can create an Auto Scaling Group from the EC2 Console, CLI, or API. The first step is to make sure that I have a suitable Launch Template (it should not specify the use of Spot Instances). Here’s mine:
Then I navigate to my Auto Scaling Groups and click Create Auto Scaling group:
I click Launch Template, select my ProdWebServer template, and click Next Step to proceed:
I name my group and select Combine purchase models and instances to unlock the new functionality:
Now I select the instance types that I want to use. The list is prioritized: instances at the top of the list will be used in preference to those lower down when On-Demand instances are launched. My app will run fine on M4 or M5 instances with 2 or more vCPUs:
I can accept the default settings for my group’s composition or I can set them myself by unchecking Use default:
Here’s what I can do:
Maximum Spot Price – Sets the maximum Spot price that I want to pay. The default setting caps this price at the On-Demand price.
Spot Allocation Strategy – Control the amount of per-AZ diversity for the Spot Instances. A larger number adds some flexibility at times when a particular instance type is in high demand within an AZ.
Optional On-Demand Base – Controls how much of the initial capacity is made up of On-Demand Instances. Keeping this set to 0 indicates that I prefer to launch On-Demand Instances as a percentage of the total group capacity that is running at any given time.
On-Demand Percentage Above Base – Controls the percentage of the add-on to the initial group that is made up of On-Demand Instances versus the percentage that is made up of Spot Instances.
As you can see, I have full control over how my group is built. I leave them all as-is, set my group to start with 4 instances, choose my VPC subnets, and click Next to set up my scaling policies, as usual:
I disable scale-in for demo purposes (you don’t need to do this for your group):
I click past the Configure Notifications, and indicate that I want to tag my group and the EC2 instances in it:
Then I review my settings and click Create Auto Scaling Group to move ahead:
My initial group of four instances is ready to go within minutes:
I can filter by tag in the EC2 Console and display the Lifecycle column to see the mix of On-Demand and Spot Instances:
I can modify my Auto Scaling Group, reducing the On-Demand Percentage to 20% and doubling the Desired Capacity (this is my demo-mode way of showing you what happens when the group scales out):
The changes take effect within minutes; new Spot Instances are launched, some of the existing On-Demand Instances are terminated, and the composition of my group reflects the new settings:
Here are a couple of things to keep in mind when you start to use this cool new feature:
Reserved Instances – We plan to add support for the preferential use of Reserved Instances in the near future. Today, if you own Reserved Instances, specify their instance types as early as possible in the list I showed you earlier. Your discounts will apply to any On-Demand instances that match available Reserved Instances.
Weight – All instance types have the same weight; we plan to give you the ability to specify weights in the near future. This will allow you to specify custom capacity units for each instance using either memory or vCPUs, and to specify the overall desired capacity in the same units.
Cost – The feature itself is available to you at no charge. If you switch part or all of your Auto Scaling Groups over to Spot Instances, you may be able to save up to 90% when compared to On-Demand Instances.
ECS and EKS – If you are running Amazon Elastic Container Service (Amazon ECS) or Amazon Elastic Kubernetes Service (EKS) on a cluster that makes use of an Auto Scaling Group, you can update the group to make use of multiple instance types and purchase options.
This feature is available now and you can start using today in all commercial AWS regions!