AWS Cloud Financial Management

Optimize costs by automating AWS Compute Optimizer recommendations

In today’s dynamic cloud computing landscape, optimizing costs and maximizing resource efficiency are top priorities for organizations of all sizes. As businesses expand their cloud operations, they often face the challenge of managing large infrastructures, including numerous Amazon Elastic Compute Cloud (Amazon EC2) instances. While these instances offer tremendous flexibility and scalability, they can also present a challenge in ensuring that resources are utilized efficiently and cost-effectively.

This is where AWS Compute Optimizer steps in. AWS Compute Optimizer is a powerful tool that offers recommendations to optimize your Amazon EC2 instances, helping you identify suitable instance types, reduce underutilized resources, and enhance performance. In this blog post, we will explore AWS Compute Optimizer and demonstrate how to automatically apply its recommendations, resulting in significant cost savings and improved resource efficiency.

What Is AWS Compute Optimizer?

AWS Compute Optimizer, a service offered by Amazon Web Services (AWS), examines the configuration and utilization metrics of your AWS resources to provide recommendations. The service offers a suite of APIs and a user-friendly console interface to assist customers in minimizing costs and enhancing workload performance by suggesting the most suitable AWS resources for their workloads.

It evaluates historical utilization metrics to identify optimal configurations for various AWS services, including Amazon Elastic Compute Cloud (EC2) instance types, Amazon Elastic Block Store (EBS) volume configurations, task sizes for Amazon Elastic Container Service (ECS) on AWS Fargate, AWS Lambda function memory sizes, and license recommendations for commercial software running on Amazon EC2.

How do you automate the implementation of AWS Compute Optimizer Recommendations?

While AWS Compute Optimizer provides rightsizing recommendations for various AWS services, we will focus on Amazon EC2 instances in this blog.

To streamline the implementation of AWS Compute Optimizer recommendations, we can take advantage of the following solution (see the architecture below). This solution is constructed around an AWS Step Function, which efficiently orchestrates the optimization process. It also uses Amazon EventBridge, AWS Lambda, Amazon Simple Notification Service, and Amazon API Gateway to seamlessly implement the recommendations.

Figure 1. The diagram shows how to automate the implementation of AWS Compute Optimizer Recommendations

Figure 1. The diagram shows how to automate the implementation of AWS Compute Optimizer Recommendations

Here’s how it works:

  1. Customizable Schedule: Amazon EventBridge Scheduler triggers the execution of an AWS Step Function bi-weekly (default schedule).
  2. Data Collection: The AWS Step Function calls the AWS Compute Optimizer API to retrieve the latest recommendations for Amazon EC2 instances. A template of AWS resource specific actions to process is created.
  3. Parallel Processing: Each resource recommendation is processed in parallel by the solution to determine if it corresponds to an overprovisioned resource and whether it aligns with the customers defined risk profile.
  4. Optional User Approval: If enabled, the solutions send an approval request via SNS and API Gateway before making any changes. This ensures customers have the final approval in their resource modifications.
  5. Maintenance Window: The solution waits until the next maintenance window before applying any changes to customer resources. This allows for controlled and scheduled updates, minimizing disruption.
  6. Rollback: In case of any errors during the resource update process, the solution automatically rolls back the resource to its original configuration and notifies the customer about the issue.

Benefits

  1. Continuous Cost Optimization: AWS Compute Optimizer provides ongoing recommendations to ensure that your cloud resources are right-sized. By automating the implementation of these recommendations, customers achieve continuous cost optimization, reducing unnecessary expenses as their workloads and underlying resources change.
  2. Resource Efficiency: Ensures that your resources are optimized to manage your workloads resulting in improved performance and efficiency.
  3. Reduced Manual Work: Manual resizing of instances is time-consuming and error-prone. This automated solution minimizes the need for manual intervention and the risk of human errors.
  4. Risk Mitigation: Risk profiles enable customers to define a threshold based on their risk tolerance ensuring that only business approved recommendations are implemented.
  5. Scheduled Changes: Designated maintenance windows define when changes can be implemented minimizing disruptions to customer operations.
  6. Rollback Mechanism: In the event of any issues during the resource update process, the solution provides a rollback mechanism to return resources to their original configuration.
  7. Email Approvals: Customers have the option to enforce email approval before changes can be executed adding an extra layer of control.

With AWS Compute Optimizer and this automation solution, you can effortlessly optimize your Amazon EC2 instances, reduce costs, and enhance resource efficiency, ultimately maximizing the value of your cloud resources. Automating AWS Compute Optimizer recommendations simplifies the process and ensures that your infrastructure remains cost-effective and optimized.

Getting started with the solution deployment

Now that we have a clear understanding of what AWS Compute Optimizer is and how we can automate the process, let’s put everything into action. In order to implement this solution, you have to do the following:

1.  Enable AWS Compute Optimizer:

If you haven’t already, enable AWS Compute Optimizer on the AWS account where you want to automate recommendations:

a. On the AWS Management Console, navigate to AWS Compute Optimizer and click on “Get started.”

Figure 2. The image shows how to activate AWS Compute Optimizer

Figure 2. The image shows how to activate AWS Compute Optimizer

b. Validate and update the settings, then click on “Opt-in.”

Figure 3. The image shows how to Opt-in on AWS Compute Optimizer

Figure 3. The image shows how to Opt-in on AWS Compute Optimizer

2.  Deploy the solution:

After enabling AWS Compute Optimizer, deploy the automation solution:

a. On the AWS Management Console, navigate to AWS CloudFormation

b. Choose “Create stack“.

Figure 4. The image shows how to create a new AWS CloudFormation Stack

Figure 4. The image shows how to create a new AWS CloudFormation Stack

c. Select “Upload a template file” and upload the template available in the GitHub repository.

d. Define a name for the stack, which will serve as the prefix for all created resources.

e. Update the following parameters:

  • i. ArchitecturalChange: Defines if the automation will consider recommendations that involve changes to the type of processor.
  • ii. ConcurrencyLimit: Sets the limit for the number of concurrently executed Lambda functions.
  • iii. Email: Specifies the email for sending notifications related to change approvals and rollbacks.
  • iv. EmailApproval: Defines if the automation will send an approval email before implementing changes.
  • v. ExcludeTag: Identifies the tag used to exclude resources from resizing.
  • vi. MaintenanceWindowDay: Determines the day when the automation will apply changes.
  • vii. MaintenanceWindowTime: Sets the time for implementing changes.
  • viii. RiskProfile: Specifies the maximum risk tolerance for recommendations, ensuring that high-risk recommendations are not considered.

f. The solution creates IAM resources, so it is required to acknowledge the message and select “Submit

After deploying the solution, the automation will be scheduled to run on the first and third Monday of every month.

Conclusion

In conclusion, AWS Compute Optimizer is a service for customers to maximize the value of their cloud resources. In this post, we showcased how serverless components can be utilized to build a workflow that seamlessly integrates these recommendations and automatically applies them to Amazon EC2 instances. By harnessing the power of AWS Compute Optimizer recommendations and automating their implementation, you can enjoy the benefits of optimized resources and substantial cost savings, leading to a more efficient and cost-effective cloud operation.

Unlock the full potential of AWS Compute Optimizer, embrace automation for your recommendations, and embark on a journey toward an optimized, cost-efficient cloud environment that drives your organization’s success.

Alonso de Cosio

Alonso de Cosio

Alonso de Cosio is a Senior Technical Account Manager at AWS. In his role, he provides advocacy and strategic technical guidance to help customers plan and build solutions using AWS best practices. He is passionate about building modular and scalable enterprise systems on AWS using serverless technologies. Beyond work, Alonso enjoys spending time with his wife and dog, as well as going to the beach and traveling.