Improperly sized EC2 instances can have a dramatic impact on both cloud costs and workload performance.
Workloads lacking adequate resources are at risk of running out of CPU or memory. Autoscaling can help address this risk, but it doesn’t always guarantee that workloads will remain stable during periods of high demand. By right-sizing EC2 instances, you can achieve an optimal balance between instance cost and performance.
EC2 right-sizing is the process of choosing the best instance types for workloads hosted on Amazon EC2 to optimize costs. Amazon offers several hundred EC2 instances at varying prices. Each type provides different levels of virtual CPU and memory resources. Some instances also come with special features, such as access to GPUs to support GPU-accelerated machine learning workloads. Choosing an instance that provides more CPU, memory or other resources than your workloads actually require would result in overspending.
Admins should understand the main types of instances within the EC2 family to get a sense of which types of images are likely to be the best fit for particular workloads. For example, it’s typically more cost-effective to run workloads with high memory requirements using a memory-optimized instance than it would be to force the workload into a general-purpose instance.
Right-sizing should be a systematic, continuous practice — as opposed to something you do in ad hoc fashion on an irregular basis. Follow these right-sizing best practices to keep performance up and costs down.
Tag and track workload resource usage
You can use tags in conjunction with EC2 right-sizing to gain cost-optimization recommendations. Tags help you track instances and what you’re paying for each one.
Tracking the resources that your workloads consume on EC2 helps identify areas where you can right-size unoptimized instances.
Customers can track EC2 instance resource usage with the following:
- AWS CloudWatch. This service provides basic per-instance resource metrics.
- Third-party observability tools. By deploying these tools, including application performance management offerings, directly on the instance, you can gain visibility into how much CPU, memory and storage throughput specific applications or processes consume.
Use right-sizing tools
There are a variety of tools that can help you right-size EC2 instances. Amazon offers some native tools, including the following:
AWS Compute Optimizer. Uses AI to generate cost-optimization recommendations.
AWS Cost Explorer. Helps you better understand spending in order to identify workloads where you’re overpaying.
Third-party platforms, such as Densify and IBM Turbonomic, can automatically analyse EC2 instances to identify wasted spending. In some cases, they can also automatically migrate workloads to more cost-effective instance types.
Cost consideration
The cost of EC2 instances can vary depending on which pricing model you select. On-demand pricing, for example, costs more than if you reserve an instance in advance. However, identifying the best pricing model for your workloads is different than right-sizing the instances. Both are important cost-saving measures, but EC2 pricing model selection shouldn’t be conflated with EC2 instance right-sizing.
Make right-sizing a continuous practice
Workloads change over time, so strive to make EC2 right sizing an ongoing process. Often, an EC2 instance type that initially provided good value no longer does because your workload no longer needs the same CPU, memory or other resources.
Cost-monitoring tools that run continuously can also help to provide ongoing review of EC2 instance types. If you don’t use those tools, you can at least require evaluations of instance selections on a regular basis. This could be once a month and coincide with payment of your AWS bill.