10 best practices to reduce AWS EC2 costs

EC2s are at the core of AWS deployments and can typically account for up to 45% of your AWS bill. Implementing cost best practices for EC2s pays dividends!We cover the 10 best practices to reduce AWS EC2 costs including choosing the right instance type, making use of ARM and AMD CPU types, choosing the correct volume types, saving plans.
March 7, 2023
3
min. read
Tal Shladovsky

TL;DR

EC2s are at the core of AWS deployments and can typically account for up to 45% of your AWS bill. Implementing cost best practices for EC2s pays dividends!

We cover the 10 best practices to reduce AWS EC2 costs including choosing the right instance type, making use of ARM and AMD CPU types, choosing the correct volume types, saving plans.

In this blog post, we will go over 10 best practices to optimize AWS EC2 costs.

Amazon Web Services (AWS) Elastic Compute Cloud (EC2) is one of the basic building blocks of any AWS deployment. As your compute requirements grow, EC2 instances can quickly become a significant expense for your organization. Fortunately, several ways exist to optimize your EC2 usage and reduce your AWS bill.

Here are 10 best practices to reduce AWS EC2 compute costs:

1. Choose the right EC2 instance type:

EC2 offers various instance types optimized for different use cases, such as compute-intensive, memory-intensive, or storage-intensive workloads. The new generation instance types provide even better performance and lower costs. By selecting the right instance type for your needs, you can avoid overprovisioning and paying for unnecessary resources. As an example, use M6I instead of M5 instance types. The smaller/simpler the instance, the less you pay.  
You can learn more about AWS instance types and AWS’s recommendations on the AWS blog.

2. Make use of ARM-based or AMD instances where you can:

Compared to Intel based CPUs, using AMD or Graviton ARM-based instances can reduce costs for your AWS EC2 usage. However, performing thorough testing to compare the performance with Intel-based CPUs and ensure compatibility with your code is essential. AWS Graviton ARM-based instances outperform intel-based instances in some application and database benchmarks.

As an example, price comparison looks like the table below:

AWS EC2 price comparison by CPU type, as of 2023-02-27

You can learn more about EC2 Graviton and EC2 AMD instances on the AWS website.

3. Choose the correct volume type for your workload: and adjust the size of the volumes based on your needs. Use the proper volume configurations (IOPS, Size) and new generation (GP3) options that offer better performance and lower cost. Read our blog post on GP2 and GP3 volumes to learn how Lightlytics can help you find and migrate to optimal volume types.

4. Use Saving Plans or Reserved Instances:

AWS offers Saving Plans or Reserved Instances that allow you to commit to a one or three-year term for a specific instance type. In exchange for this commitment, you receive a significant discount on the hourly rate of the instance. You can save up to 72% on your EC2 costs by purchasing AWS Saving Plans or Reserved Instances.

5. Use Spot instances:

Spot instances are unused EC2 instances that AWS offers at a significant discount compared to on-demand instances. Spot instances can be a great way to save costs for workloads that can handle interruptions or have flexible deadlines. Use AWS Spot fleet to manage your spot instances and automatically scale your capacity based on your needs.

6. Use auto-scaling groups

Auto-scaling groups allow you to automatically scale the number of EC2 instances based on your workload. By using auto-scaling groups, you can ensure that you have enough capacity to handle traffic spikes and scale down during periods of low usage. This can help you avoid overprovisioning and paying for idle instances. Read AWS’s article on auto-scaling groups to learn more.

7.Detect and shrink underutilized instances:

Detect and analyze your instances to identify underutilized instances and consider resizing or downgrading them to a smaller instance type. This can help you save on EC2 costs without affecting the performance of your applications. Read AWS’s right-sizing tips to learn more.

8. Detect and remove unused and idle resources:  

Periodically review your AWS environment and identify any unused resources, such as EC2, EBS snapshots, or EBS volumes, and delete them to save on storage costs.
Remove unused instances that are in a stopped state, as they can still incur costs. You can automate this process by using AWS Lambda or a third-party tool.

9. Stop non-production instances when they’re not in use

In dev/staging environments, stopping EC2 instances during off-work hours is recommended.
Read more how you can stop and start EC2 instances at regular intervals using Lambda here.

10. Use solutions like Karpenter in EKS clusters

Automatically adapt the number of EC2s to the resources your microservices need.
Read more on Karpenter best practices here.

Use tools to detect saving opportunities automatically!

AWS Trusted Advisor is a tool that provides real-time guidance to help you optimize your AWS infrastructure. Trusted Advisor checks your account for best practices in cost optimization, security, fault tolerance, and performance. By using Trusted Advisor, you can identify areas of improvement and reduce your AWS bill. The Trusted Advisor functionality depends on the support level set on the AWS account.

Lightlytics is a change intelligence platform enabling real-time checks against the current state and every newly introduced change. Using Lightlytics, you can instantly detect saving opportunities, unused and underutilized resources, while having all the context for each resource, like who created it, when it was last used, and more.

Try Lightlytics free for 21 Days, and find saving opportunities the moment you connect the AWS account. Sign up for a free trial.

Liked this post? 

Read Stav's (co-founder & CTO @Lightlytics) blog post on Democratizing cloud costs.

Read Tal's hands-on guide series on AWS cost reduction: 

What's new