- Pricing & Cost Optimization
AWS ECS Pricing and Container Optimization Guide
Containers are a standardized package of software that runs reliably in different computing environments. They hold everything you need to run an application, including the code, runtime environment, system tools, libraries, and settings. You can use containers to run anything you want, from microservices to applications.
With AWS ECS, Amazon orchestrates the containers and provides developers the ability to automate and scale container deployment and upkeep. Unlike AWS EKS(Elastic Kubernetes Service), there is no cost for running an orchestration cluster. With AWS ECS pricing, you only pay for the underlying resources your containers use.
Containers serve very similar purposes to virtual machines but use slightly different methodologies. Virtual machines run as tiny computers, installing their own fully sandboxed operating systems and interacting with the host machine through the hypervisor. Containers don’t install an operating system, or use the hypervisor; instead they share the OS kernel with the host machine, so they take up less memory and often need fewer resources to start.
This article will provide a quick summary of AWS ECS pricing and strategies for keeping your costs low while effectively using ECS services. Because Batch utilizes AWS ECS and Fargate to execute containerized jobs, I’ll focus on cost-management practices for those services. However, be aware short-running containers that benefit from parallelization might be most at home using the Batch service.
- AWS ECS Pricing: Fargate vs EC2 Launch Type
- Tagging AWS ECS Elements
- AWS Discounts
- AWS ECS Container Optimization
Looking For Other AWS Cost Guides?
- CloudFront Pricing and Cost Optimization Guide
- DynamoDB Pricing and Cost Optimization Guide
- EMR Cost Optimization Guide
- NAT Gateway Pricing and Cost Reduction Guide
- RDS Pricing and Cost Optimization Guide
- S3 Pricing and Cost Optimization Guide
- Tagging Best Practices and Strategies
AWS ECS Pricing: Fargate vs EC2 Launch Type
There are two models for AWS ECS pricing (and one more customized use case). The AWS Fargate launch Type is the simplest; you’re charged per second (with a one-minute minimum) for each vCPU and GB of memory your container requests, starting when your container image is pulled through to the second it shuts down. Be aware that you currently can’t use the Fargate launch option with Windows containers.
You can also choose the AWS EC2 launch type, which will be familiar to many AWS users. Under this model, you pay for the AWS EC2 instances and attached EBS volumes that you select to run your containers. You can get bigger discounts with this model, but because instances are a fixed size, you have to be relatively certain about the requirements of your containers and avoid choosing an EC2 instance that’s too large or small.
If your situation requires keeping data on-premise, or your application has strict low latency requirements, you can also choose to host ECS services on an AWS Outpost, where AWS brings a server to you and installs it. This option is more expensive, and you’ll pay between a 26 and 41 percent premium for using this service.
Tagging AWS ECS Elements
The first step toward reducing the cost of any AWS service is opening Cost Explorer and taking an inventory of your current utilization. Tagging is an excellent tool to help you understand how your organization is using containerized applications and helps you find orphaned resources that can quietly drive up costs. Tagging is also helpful for implementing programmatic infrastructure management and granular permissions.
With AWS ECS, there are a few working parts to tag:
Tagging these elements will help you better utilize the Cost Explorer, allowing you to organize your AWS ECS resources by team, environment, or product. You can use CloudForecast’s Monthly Tagging Report to quickly find and discover untagged AWS ECS resources.
Once you’ve decided what AWS ECS pricing model suits (Fargate Launch Type vs EC2 Launch Type) your needs and have your resources tagged properly, you can start to reduce your costs by optimizing where and how your clusters run.
Choosing an AWS Region
As with most AWS services, prices vary by region. At the time of writing, the most expensive region for Fargate services was São Paulo, where you pay $0.0696 per vCPU per hour and $0.0076 per GB per hour. There is a tie for cheapest region between Ohio, Virginia, and Oregon, where you pay $0.04048 per vCPU and $0.004445 per GB. That’s more than a 70 percent price difference, so if you’re running more than a few containers, choosing an economical region can have a huge impact on your monthly bill.
Keep in mind that AWS also charges per GB for many types of data transfer, so you’ll have to balance the value of getting a cheaper rate in a certain zone against the costs of getting your data where it needs to go.
AWS Savings Plans: EC2 & Fargate
These Savings Plan prices come in two flavors: Compute and EC2 Instance. Both Fargate and EC2 are eligible for Compute Savings Plans, which apply to usage “regardless of instance family, size, AZ, region, OS, or tenancy.” For one-year commitments, Savings Plans offer discounts between 20 and 30 percent. If you’re able to commit to the three-year plans, those discounts approximately double to around 50 percent. Paying this cost up front adds an additional discount of about 5 percent, so if you’re sure you’ll use containers regularly and have cash on hand, you can save about 55 percent paying up front for a three-year-long commitment.
EC2 Instance Savings Plans offer even steeper discounts but are less flexible. First of all, Fargate customers can’t use these plans, and you’re locked into a specific EC2 Instance family and region for the duration of your term. However, these discounts can reach as high as 72 percent, so if you’re sure you’ll use the instances, this is a great option.
For help choosing a Savings Plan that works for you, you can look at Cost Explorer, which analyzes your historical uses and suggests plans that might fit your workload.
AWS Spot Instances
Spot Instances are another way to purchase computing power at a steep discount. AWS allows customers to purchase unused capacity, but if the capacity is purchased by another user, it will be reclaimed with a two-minute warning. These discounts change slowly based on market demand; currently they are 67 percent for Fargate compute and up to 90 percent for EC2 Instances.
These discounts are significant, but you have to be sure your containers won’t be upset by being turned off without much warning. Spot Instances are best for container services that are stateless, fault-tolerant, or don’t have specific availability requirements, like data processing or image rendering tasks.
AWS ECS Container Optimization
Selecting cost-effective options is a great starting point for reducing your AWS spend, but you also have to monitor and optimize the containers you’re running to make sure they’re using resources efficiently.
Because the AWS Fargate launch type charges your container for the resources it requests, and you pay for the size of your instances with EC2, a great way to reduce cost is to audit your containers and assign them the appropriate resources to handle their workload.
Container resources are often allocated once, then never reevaluated. Load testing your container applications can help you minimize the amount of resources a container requests, while ensuring that your application can handle its workload. AWS offers a custom distributed load testing solution for AWS Fargate that can help you establish your performance requirement under load, but be aware that this solution will incur costs as it utilizes several AWS services. Their solution implements the Taurus framework to run tests, so you can also investigate creating your own load testing.
Your Cloudwatch dashboard can also provide valuable insights into utilization. It might be worthwhile to pay for additional monitoring with a custom dashboard while establishing or auditing your ECS utilization levels.
To further optimize container usage, particularly with unpredictable workloads, look into auto scaling the tasks running in your cluster. This is particularly useful for test and development environments, which might only have to be available during working hours. You can run tasks on a
cron schedule attached to CloudWatch metrics, write your own scheduler, or use a library like Blox.
AWS ECS Container Consolidation
Another option for container optimization is to consolidate smaller or similar services into a single container. For example, if you have a container to handle internal traffic and a container to handle external traffic, be aware that ECS supports multiple load balancer target groups, which could allow you to consolidate the two services into a single container.
AWS ECS and Fargate pricing offer a lot of flexibility in terms of payment options. Audit your requirements, then select a mixture of services that best suit your needs. Tag and track container utilization to make sure you’re purchasing the right amount of compute, and consider whether or not your containers could benefit from auto scaling or consolidation.
With experience helping clients like Coffee and Bagel monitor and reduce their ECS costs, and tools like daily monitoring and tagging compliance reports, CloudForecast can help you focus on technical challenges while we monitor financial reporting for your AWS resources. Reach out to our CTO, firstname.lastname@example.org, if you’d like help implementing a long-term cost-reduction strategy.
John is a freelance software engineer based in Chicago who writes about hosting and cloud computing topics.
Manage, track, and report your AWS spending in seconds — not hours
CloudForecast’s focused daily AWS cost monitoring reports help busy engineering teams understand their AWS costs, rapidly respond to any overspends, and promote opportunities to save costs.
Subscribe To Our Newsletter
Subscribe to get our latest news, features, and any updates.
AWS Cost Management Is Made Easy With CloudForecast
We would love to learn more about the problems you are facing around AWS cost. Connect with us directly and we’ll schedule a time to chat!