5 Key Approaches to Cost Optimization on Amazon ECS and AWS Fargate
Feb 16, 2023
Amazon Elastic Container Service (ECS) and AWS Fargate are two popular AWS container-related services. Amazon ECS is a fully-managed container orchestration solution for deploying, maintaining, and scaling containerized apps. AWS Fargate is a serverless compute engine for containers that is compatible with ECS. When used together, Amazon ECS and AWS Fargate are a powerful combination for delivering modern applications to customers worldwide.
However, many users of the AWS Fargate / Amazon ECS combination are overspending for what they need. This is happening for a variety of reasons, and it’s preventing companies from maximizing ROI on the cloud. The good news is that optimizing costs on these services is relatively easy.
In a previous post, we looked at cost optimization strategies for Kubernetes. Now, in this post, we cover 5 strategies for cost optimization on Amazon ECS and AWS Fargate costs:
- Improve cost visibility
- Profile applications continuously
- Implement autoscaling
- Leverage Graviton and Spot Instances
- Consider savings plans
1. Improve Cost Visibility
The first step for cost optimization on Amazon ECS is to be more aware of the primary cost buckets. Organizations spend most of their money on workloads, compute, and operating costs, i.e., labor. AWS Fargate enables teams to reduce their OPEX burden significantly by eliminating the need to patch and upgrade a host/OS.
On the workload and compute front, AWS offers several tools to increase cost visibility: AWS Cost Explorer and AWS Compute Optimizer. AWS Cost Explorer allows engineers to view costs and usage hours by usage type. Teams can also enforce tagging policies to improve cost allocation and increase visibility into specific workloads. Tagging is critical for staying organized and updated on how money is being spent.
AWS Compute Optimizer provides recommendations on how to rightsize workloads based on actual utilization data. AWS Compute Optimizer integrates directly with AWS Fargate, giving engineers clear insight into where they may be overprovisioning resources related to Amazon ECS task CPU and memory.
With both of these tools, it’s important to monitor costs and analyze spending patterns regularly, as well as to set up periodic notifications. Building this habit is essential for ensuring costs stay aligned with utilization and need.
2. Profile Applications Continuously
Application profiling is all about understanding what every part of an application requires when it comes to CPU and memory. Application profiling should identify baseline resource needs, as well as peak performance requirements. Being aware of these metrics gives engineers the ability to finetune resource allocations and implement auto-scaling policies that strike the balance between performance and cost.
According to a 2020 Datadog report, 49% of container deployments use less than 30% of requested CPU. Similar underutilization happens on the memory side – 45% of containers use less than 30% of requested memory. A tool like Amazon Cloudwatch Container Insights helps avoid this by bringing critical metrics to light, such as average CPU and average memory consumed vs. average CPU and average memory reserved. This data can then be used to refine resource allocations over time.
Other best practices include loading test applications to determine resource requirements at scale with a tool like Distributed Load Testing on AWS and profiling applications continuously. This prevents overprovisioning and keeps resources in line with utilization.
3. Implement Autoscaling
Another way to reduce costs is to leverage AWS Application Auto Scaling. ECS comes with built-in autoscaling for tasks when used in conjunction with Fargate. Autoscaling can also happen at the service level. This is possible when combining Amazon Cloudwatch insights with AWS Auto Scaling capabilities.
ECS offers three types of autoscaling: target tracking, step scaling, and scheduled scaling. Target tracking involves setting a scaling metric that an auto-scaling group should aim to hit at all times. Step scaling allows teams to implement nuanced step adjustments depending on how much traffic is surging. And scheduled scaling involves defining a time span for when resources will be added. The right scaling policy depends on the unique needs of the organization.
4. Leverage Graviton and Spot Instances
AWS offers several ways to optimize compute costs. First, AWS Graviton is a service that gives organizations access to powerful and cost-efficient server processors built for a wide range of workloads. AWS now has Graviton2 and Graviton3 instances that deliver incredible price performance and support container operations. Adopting Graviton instances is an effective way to ensure maximum compute return.
Spot Instances give AWS users a way to purchase spare EC2 capacity at a heavy discount. With Fargate Spot, engineering teams can save up to 70% off on-demand prices. Spot Instances are a great way to cut compute costs for those who have flexibility around the exact types of instances, sizes, and Availability Zones they need. Spot Instances are especially well-suited for applications that can tolerate unexpected terminations.
5. Consider Savings Plans
The last way to cut costs when using ECS and Fargate is to take advantage of AWS’ Compute Savings Plans. These are particularly valuable for organizations that can commit to minimum usage levels over a certain period of time. Savings plans discounts on CPU and memory can reach up to 52% depending on the plan chosen by the customer. Anything used above the purchase plan is charged at the on-demand rate.
One way to think about savings plans is to use them for steady-state workload capacity. Spot instances can then work well for fault-tolerant and flexible compute, while on-demand instances can handle spikey, stateful workloads. The right combination of these purchase options can save companies major money without sacrificing performance at any demand level.
Start Cost Optimization on Amazon ECS and AWS Fargate Today
With these strategies, engineering teams can cut wasteful spending immediately for container-related operations. Better visibility into utilization, continuous monitoring, autoscaling, and a deeper understanding of the pricing options AWS offers are what it takes to keep costs aligned closely with demand.
For those who need help or guidance on where to begin, ClearScale is here. Our cloud experts know the ins and outs of all the tools and solutions mentioned above, as well as how to lead organizations through any cost optimization project.
Get in touch today to speak with a cloud expert and discuss how we can help:
Call us at 1-800-591-0442
Send us an email at sales@clearscale.com
Fill out a Contact Form
Read our Customer Case Studies