Get 15% better price performance by retyping your EC2 AutoScaling Groups – Deep Dive

You can reduce EC2 costs simply by re-typing your instances. Is it risky? Yes, it is. Check out this tech blog on how to achieve this cost fix safely. - Deep Dive

Before you start

Go through the checklist and see if this cost fix applies to your use case. As per best practices, make sure to test the upgrade in a safe environment first. Plan the upgrade using maintenance windows for production instances. This gives you time to perform checks and changes, and revert in case of problems.

Checklist

  • Instance type family M5
    We start with M5 since it is one of the most widely used instance types in AWS. Other instance types introduce variables in the decision making process that make description of the migration process hard. We are all about making it easy.
  • ASG with automatic scaling policies, or at least one Spot instance
    That is a sure indicator that instances can be launched and stopped without user participation. You could upgrade other instances as well, but you will need to make sure that they can be launched automatically.
  • M6i availability in your AZ
    You can check this using the following command, just update the AZ values and region to fit your needs:
				
					aws ec2 describe-instance-type-offerings --location-type "availability-zone" --filters Name=location,Values=us-east-2a --region us-east-2
				
			
  • No reserved instances You should not upgrade reserved instances, since reservations are type-bound. If you change the type of reserved instances, you will incur duplicate costs.

Best upgrade strategy for your use case

Is it better to replace M5 with M6i, or is it better to add M6i with a higher priority in your ASG launch configurations? Do you need to update the ASG strategy? Check the following use cases on how to apply the best upgrade strategy for your needs.

3rd party tools or Infrastructure as Code?

Do you run your ASGs using 3rd party tools such as AutoSpotting? Do you use Infrastructure as Code? Before attempting any changes, check the relevant documentation and user forums for guidelines and recommendations.

Single instance type ASG

Copy the launch configuration changing the instance type to the corresponding M6i instance type, then update the ASG to use the new configuration.

If you use Launch Templates, check which version the ASG is pointing to. Then make a copy of the current configuration to a new template and change the instance type to the corresponding M6i instance type. If your ASG uses explicit version numbers, increase the version by 1. If the current template is marked as default, mark the new template as default.

Mixed instance type ASG

In this case we recommend adding the new instance type with a higher priority to your set of launch configurations. This allows for better Spot coverage, as per AWS recommendations: Picking older-generation instance types that are less popular tends to result in lower costs and fewer interruptions.

For each M5.* instance type, copy the whole configuration – including WeightedCapacity and LaunchTemplateSpecification – to a row above, changing the type to the corresponding M6i instance type.

If M5 was top of the list and the ASG uses the capacity-optimized strategy, be sure to enable Prioritize Instance types. This will ensure the M6i is preferred over M5.

Avoid service degradation or disruption

The easiest and cheapest way is to upgrade instances in-place. However, based on the workload and your configuration, this might lead to service degradation or disruption under high load. It is much safer to temporarily increase the desired capacity to add the new instance types.

Instructions

  1. Open the EC2 dashboard and select the ASG you want to upgrade
  1. Apply the changes to the Launch Configurations depending on your use case – see instructions above
  2. Enable scale in protection for the ASG
  1. Enable scale in protection for the instances you don’t need to update
  1. Increase the desired capacity by the number of instances to upgrade, plus the number of instances in the warm pool. Increase the maximum capacity if needed.
  1. Wait until the ASG is upgraded. It takes a couple of minutes to adjust the group to the new desired capacity.
  2. Verify your ASG launched at least one m6i instance, and its health status.
  3. Restore desired and maximum capacity.
  4. Wait roughly one minute for the ASG to scale down.
  5. Restore scale in protection settings for both the ASG and the instances.

Conclusion

Once the availability and upgrade compatibility are checked, this is a secure cost fix. It increases the effectiveness of your EC2 ASG and cuts costs when less instances are needed. Performing all these checks will require some time. If you prefer a simple automated solution, try CloudFix that can apply such fixes for you.

References

  • Amazon EC2 M6i Instances – Amazon Web Services. (n.d.). Amazon Web Services, Inc. Retrieved October 18, 2021, from Read more
  • Migrate to a sixth generation EC2 instance. (n.d.). Amazon Web Services, Inc. Retrieved October 19, 2021, from Read more
  • Auto Scaling groups with multiple instance types and purchase options – Amazon EC2 Auto Scaling. (n.d.). AWS User Guide. Retrieved October 19, 2021, from Read more
  • Deep Dive Into AWS Nitro System (49:37). (n.d.). Amazon Web Services, Inc. Retrieved October 20, 2021, from Read more
  • GitHub – cloudutil/AutoSpotting: Saves up to 90% of AWS EC2 costs by automating the use of spot instances on existing AutoScaling groups. Installs in minutes using CloudFormation or Terraform. Convenient to deploy at scale using StackSets. Uses tagging to avoid launch configuration changes. Automated spot termination handling. Reliable fallback to on-demand instances. (n.d.). GitHub. Retrieved October 20, 2021, from Read more
  • SpotOptions – Amazon Elastic Compute Cloud. (n.d.). AWS API Reference. Retrieved October 22, 2021, from Read more
  • Warm pools for Amazon EC2 Auto Scaling – Amazon EC2 Auto Scaling. (n.d.). AWS User Guide. Retrieved October 26, 2021, from Read more

More Updates

Reduce Costs

CloudFix now supports Financial Savings

Since the launch of CloudFix cost optimization platform from DevGraph we have seen huge interest and adoption. Today, we are excited to announce that you can save even more with our new financial savings capabilities in addition to resource related

Read More
Skip to content