Amazon Web Services (AWS) customers can access information in the AWS Management Console, Amazon CloudWatch, and AWS Trusted Advisor to gain insight into their service usage and estimated costs. This information can help organizations better understand how to leverage the elasticity and flexibility of the AWS Cloud to optimize their costs yet still meet their performance and capacity requirements.

Amazon Elastic Compute Cloud (Amazon EC2) provides a wide selection of instance types and sizes, giving customers the flexibility to right size compute resources to meet their capacity needs at the lowest cost. Amazon EC2 also generates detailed usage data to help determine how to better right size instances to meet the technical requirements of a given workload.

AWS offers the Cost Optimization: EC2 Right Sizing (EC2 Right Sizing) solution, which uses managed services to perform a right-sizing analysis and offer detailed recommendations for more cost-effective instances. The following sections provide an overview of the solution as well as high-level best practices for optimizing your Amazon EC2 costs.

The flexibility and elasticity of the AWS Cloud enables you to right size your instances to meet your performance and capacity requirements. Regularly monitor Amazon EC2 Usage Reports, which are updated multiple times a day and provide in-depth usage data for all of your Amazon EC2 instances. With this in mind, consider the following AWS best practices for optimizing Amazon EC2 costs:

  • Purchase reserved capacity to more predictably manage Amazon EC2 costs. With Reserved Instances, you pay a one-time fee to receive a significant discount on the hourly charge for the instance. To minimize your costs, the billing system automatically applies your Reserved Instance discounts first, and you can save up to 75% over equivalent On-Demand capacity when attributes of EC2 instance usage match attributes of an active Reserved Instance.
  • For short-term usage, bid on Spot instances to significantly reduce the cost of running your applications and lower your operating costs by up to 90% compared to On-Demand instances.
  • Stop Amazon EC2 instances that are not in use to reduce operational costs in both development and production environments. Implement tools to help automate start and stop actions to maximize savings. AWS offers the EC2 Scheduler, a simple solution that allows you to create custom start and stop schedules for your Amazon EC2 instances.
  • Monitor your costs on a daily basis using AWS cost and reporting tools, such as Cost Explorer, budgets, and detailed billing reports in the Billing and Cost Management console, and the Cost Optimization Monitor solution, which uses managed services to visualize detailed billing report in a customizable dashboard.

The EC2 Right Sizing solution analyzes two weeks of utilization data to provide detailed recommendations for right sizing your Amazon EC2 instances. The diagram below presents the architecture you can automatically deploy using the solution's implementation guide and accompanying AWS CloudFormation template.

  1. The template launches an Amazon Redshift cluster, an Amazon Simple Storage Service (Amazon S3) bucket, and an Amazon EC2 instance in an Amazon Virtual Private Cloud (Amazon VPC) network.
  2. The instance hosts a series of Python scripts that upload utilization data from Amazon CloudWatch to Amazon Redshift for right-sizing analysis.
  3. The results are delivered in CSV format to the Amazon S3 bucket, and include instance-by-instance recommendations and related cost savings.
  4. This solution is intended for temporary deployment. After you save the results, you can automatically terminate the Amazon EC2 instance and Amazon Redshift cluster, and then manually delete the entire solution stack.  
Deploy Solution
Implementation Guide

What you'll accomplish:

Deploy the Cost Optimization: EC2 Right Sizing solution using AWS CloudFormation. The CloudFormation template will automatically launch and configure the components necessary to run a custom query and return detailed right-sizing recommendations.

See your potential cost savings for using new instance types. The analysis shows line items for the estimated monthly savings you will gain with each instance change.

What you'll need before starting:

An AWS account: You will need an AWS account to begin provisioning resources. Sign up for AWS.

Skill level: This solution is intended for IT infrastructure and networking professionals who have practical experience architecting on the AWS Cloud.

Q: Can I use the EC2 Right Sizing solution to analyze instance usage in linked accounts?

No. For customers who use Consolidated Billing, this solution will not analyze Amazon EC2 usage across linked accounts. You must deploy the solution separately in each account.

Q: What time period of data is used to perform the analysis?

The solution pulls the last two weeks of Amazon EC2 usage data from Amazon CloudWatch. Therefore, be aware of the impact of seasonal or business cycles on the metrics and results.  

Q: How does this solution differ from the AWS Trusted Advisor Cost Optimization check?

Both the EC2 Right Sizing solution and AWS Trusted Advisor analyze utilization on EC2 instances running any time during the last two weeks. The EC2 Right Sizing solution analyzes all instances with a max CPU utilization lower than 50% and determines a more cost-effective instance type for that workload, if available. In comparison, AWS Trusted Advisor can alert you to low utilization thresholds such as daily CPU utilization of 10% or less and network I/O of 5 MB or less on 4 or more days during the two-week period.

Each tool provides valuable information about your Amazon EC2 usage that can help you lower your costs.

Q: Can I deploy the EC2 Right Sizing solution in any AWS Region?

Customers can deploy the solution's AWS CloudFormation template only in AWS Regions where AWS Lambda is available because the service is required to configure the initial infrastructure. However, once deployed, the solution will collect usage data for all Amazon EC2 instances in your account.

Q: Should I change my instance type and size as soon as the analysis is complete to make sure I'm not overspending?

No. Before incorporating the recommended changes, we recommend that you test the proposed Amazon EC2 instances to ensure they are properly sized to fulfill their expected role and your overall business requirements.

Q: How often should I run this solution?

You can deploy this solutions as often as you want. We don't recommend you run it more than every two weeks unless you have noticed large or unexpected changes in your Amazon EC2 costs and want to use the analysis to help understand your most recent charges.

Need more resources to get started with AWS? Visit the Getting Started Resource Center to find tutorials, projects and videos to get started with AWS.

Tell us what you think