How to Remediate Amazon EC2 Low-Utilization Checks with Stratusphere™ FinOps

Learn how to tackle AWS EC2 low-utilization checks effectively with Stratusphere™ FinOps. Discover how to optimize your resources and enhance performance.

Need additional support?

Subscribe

Amazon Elastic Compute Cloud (EC2) is a cloud infrastructure service that makes it easy to deploy systems running Linux, Windows, and even MacOS. EC2 is one of the oldest services in the AWS cloud platform, dating back to a 2006 beta release, according to Wikipedia.

There are many different “sizes” of EC2 instances that you can deploy, with varying attributes including virtual CPUs, memory, temporary storage, network performance, and more. AWS regularly releases new generations of EC2 instance families (ie. c7, m7), based on new CPU architectures, providing more performance-per-watt consumed. 

Amazon CloudWatch is a monitoring service that tracks many useful metrics, including consumption of CPU and memory for Amazon EC2 instances. By default, when you deploy Amazon EC2 instances, the CloudWatch service captures periodic measurements of EC2 utilization.

Amazon EC2 Instance Sizing

When you’re selecting an EC2 instance size for deployment, you generally need to estimate, or measure, the resource consumption of your workloads, under varying load conditions. Once you’ve deployed an application to an EC2 instance, it stays running virtually indefinitely, unless you intentionally make changes to the EC2 instance configuration. 

AWS allows you to stop an on-demand EC2 instance, resize it, and then restart it with a different set of allocated resources. This technique is generally known as “vertical scaling” either up or down, however it does require workload downtime.

You can schedule periodic scaling events for predictable workloads, to increase or decrease the size of your EC2 instances, if vertical scaling is a requirement. For example, if you know that a particular EC2 instance will be under heavy load from 8 AM to 4 PM every day, you could schedule a scale-up event at 7:50 AM, and a scale-down event at 4:10 PM. Amazon EventBridge allows you to create scheduled events, which could trigger an AWS Lambda function or Step Functions workflow, which resizes your EC2 instance. 

The details of setting this up are beyond the scope of this article, but feel free to investigate this technique in more detail.

Identify Cost Risks

Stratusphere™ FinOps identifies underutilized Amazon EC2 instances across your entire AWS Organization, including multiple AWS accounts and regions. Navigating all of this data manually, in the AWS Management Console, can require a significant level of effort. Instead, Stratusphere™ FinOps displays this data in an aggregated, and easy-to-consume format.

Under the Findings section in Stratusphere™ FinOps, you can apply various filters to narrow down which cost savings opportunities are displayed. In the screenshot below, you can see that we’ve filtered to a specific company in our organization, and further filtered to Amazon EC2.

Stratushperes Findings Dashboard

 

In the Stratusphere™ FinOps user interface, one of the available cost optimization findings that can be triggered will say “Low Utilization Amazon EC2 Instances.” In these cases, there will be a corresponding AWS resource ID that indicates the exact EC2 instance that the low utilization was discovered on.

Per the AWS Trusted Advisor documentation, EC2 instances are flagged as underutilized when CPU utilization falls under 10% and network I/O is under 5 MB, for a four-day period. This resource ID can vary between cloud platforms; on AWS, it is an Amazon Resource Name (ARN). Effectively, this finding means that the EC2 instance has more CPU & memory resources allocated to it than the workload running on the EC2 instance actually requires.

If you’re interested in leveraging Stratusphere™ FinOps and onboarding your organization, please reach out to the StratusGrid sales team.

Remediation

Now that you’ve identified the low-utilization EC2 instances, it’s time to apply the appropriate optimization technique. In this case, we’ll be resizing the EC2 instance to a smaller instance type, with fewer virtual CPUs and less memory allocated.

Before you resize your EC2 instance, you’ll want to determine which instance type you should switch to. You can find the configuration details for each EC2 instance type in the Amazon EC2 On-Demand Pricing page.

To remediate this finding manually, you can follow the steps below.

  1. Login to the AWS Management Console, for the AWS account that the resource belongs to
  2. Navigate to the Amazon EC2 service console
  3. Ensure the correct region is selected
  4. Search for the EC2 instance, in the Instances list
  5. Right-click on, and stop the EC2 instance
  6. Wait for the EC2 instance to stop
  7. Right-click the EC2 instance and choose Instance Settings ▶️ Change Instance Size
  8. Select a new value for the New Instance Type field
  9. Start the EC2 instance

Amazon EC2 New Instance

NOTE: You cannot currently resize EC2 instances that have been launched using the spot pricing model. In these circumstances, the Change Instance Size option will be grayed out. If you’re using the AWS CLI, you’ll receive an error message similar to the following: “An error occurred (UnsupportedOperation) when calling the ModifyInstanceAttribute operation: Modifying 'instanceType' is not supported for spot instances.

Risks and Other Considerations

There are several considerations to keep in mind when evaluating and executing EC2 instance resizing operations:

  • Resizing requires stopping and starting the instance which will result in several minutes of downtime.
  • Instances with ephemeral instance storage will lose their storage during this change.
    • If you’re not sure if you’re using local instance storage or not, you’re most likely using EBS network volumes. Applications would need to be configured to explicitly write to a local instance storage volume.
  • Moving to a more modern CPU might require new drivers or recompiling software
    • Moving to more modern CPUs of the same architecture (e.g. x86) can sometimes require new drivers before the instance will boot. Reverting the change and restarting is a typical rollback option in these situations.
    • Moving to an entirely new CPU architecture (e.g., x86 => ARM) will often require reinstalling the operating system and/or recompiling software before it will run on the new CPU architecture. Reverting the change and restarting is a typical rollback option in these situations.
  • If you are using instance reservations, changing instance families may cause you to underutilize your commitments and double pay for compute resources.

Automated Remediation

You can use automation tools for AWS, such as the AWS CLI or AWS PowerShell module, to resize EC2 instances. There are several commands you’ll need to run, in order to stop, resize, and start each EC2 instance. The API call that actually modifies the EC2 instance type is called ModifyInstanceAttribute.

AWS CLI Commands

aws ec2 stop-instances --instance-ids i-0000000

aws ec2 modify-instance-attribute --instance-id i-0000000 --instance-type c7i.large

aws ec2 start-instances --instance-ids i-0000000

If you do not have a default region set, you can also specify the region that you’re operating against, by using the --region parameter.

AWS PowerShell Commands

You can use the AWS EC2 module for PowerShell to automate the EC2 resizing commands.

$InstanceId = 'i-000000'

Stop-EC2Instance -InstanceId $InstanceId

Edit-EC2InstanceAttribute -InstanceId $InstanceId -InstanceType c7i.large

Start-EC2Instance -InstanceId $InstanceId

Optimize Your AWS Spend with Stratusphere™ FinOps by StratusGrid

You can save large amounts of potential spend, across your entire AWS Organization, by identifying low utilization EC2 instances with Stratusphere™ FinOps, and resizing them to a smaller size. The effort required to resize an EC2 instance is relatively low, making it an easy way to reduce your monthly cloud spend.

For low-utilization applications, you may want to consider modernizing your architecture. Using a container or serverless deployment model can simplify deployment and give you even more granularity around compute resource consumption. StratusGrid can consult with you to strategize and implement a modernized architecture for your cloud workloads. Contact us today for more information.

See Stratusphere™ FinOps in Action Here:

 

Similar posts