Amazon ECS Pricing: 3 Pricing models & tips to optimize costs
Amazon Elastic Container Service (ECS) allows you to easily deploy, manage, and scale containers on AWS. It provides significant benefits such as high availability, scalability, security, deep integration with other AWS services, and more. However, pricing is also an essential factor to consider when choosing a container orchestration solution.
This post explains how ECS is priced with its different pricing models to help you estimate ECS costs for your container workloads on AWS. The post also lists use cases for the pricing models and cost optimization techniques to reduce ECS costs.
How is Amazon ECS priced?
ECS is a fully managed container orchestration service built by AWS to help you manage containers at scale. It takes care of aspects such as container lifecycle, storage, networking, high availability, etc. But the good news is that it offers all these at no additional cost.
AWS does not charge any minimum fees or upfront costs to use the ECS service. You only pay for the resources your containerized workloads use, e.g., Amazon EC2 instances, Amazon Elastic Block Store (Amazon EBS), etc.
However, there are different pricing models for Amazon ECS based on the compute platform you choose to run your ECS containers on. The following section discusses how Amazon ECS pricing varies per the compute platforms and what costs you are looking at.
Amazon ECS pricing models
Amazon ECS lets you run containers at scale on:
- AWS Fargate
- Amazon EC2
- AWS Outposts or ECS Anywhere (for running containers on-premise)
Moreover, you can configure your clusters using a mixture of two compute options for better cost optimization. We have discussed below each compute option’s use cases and how their pricing works. So let’s begin!
ECS pricing with EC2 launch type
There are no additional costs for launching and running containers with Amazon Elastic Compute Cloud (EC2). You only pay for the resources you use to run your applications, such as underlying EC2 instances and EBS storage volumes.
Furthermore, you can choose from five types of EC2 instances:
- On-demand instances
- Reserved Instances
- Spot Instances
- Savings Plans
- Dedicated Host
For more details and pricing information on EC2 instances, you can refer to the Amazon EC2 pricing page.
While it has no minimum or upfront fees, EC2 has some drawbacks. When you deploy ECS containers to EC2 instances, you need to define what instance type to use and when to scale them. You are responsible for provisioning, monitoring, upkeep, patching, and securing the underlying EC2 instances. Moreover, instances are of fixed sizes. Therefore, you must be relatively certain about the requirements of your containers to avoid choosing instances that are too small or large.
On the bright side, EC2 has its pros. You benefit from greater control it provides for customizing your infrastructure to meet your specific needs (for example, choosing network-optimized or GPU-optimized instances). In addition, it can be the cheapest option for your cloud bill if you deploy the right choice of containers to deploy on EC2. To help you choose, we have discussed the ideal workloads for EC2 below.
Use cases for EC2 instances
Amazon ECS can be ideal for workloads:
- That would benefit significantly from customization and do not need scaling quickly
- That would benefit from specialized CPUs or GPUs not available on Fargate or Lambda
- With little or no idle time
- That are constantly processing data, so you do not pay extra or have your teams turn off/on instances at all times
- Large workloads that can be optimized for cost with reserved EC2 instances, or spot instances
ECS pricing with Fargate launch type
With AWS Fargate, you pay for the compute and memory resources used by your containerized applications. But the prices are slightly higher than EC2.
The reason? Because with Fargate, AWS does all the heavy lifting of provisioning and managing the underlying servers or infrastructure.
Fargate pricing is calculated from when container images are pulled until the ECS task terminates, rounding up to the nearest second. There is also a minimum charge of one minute. For detailed pricing information and how to calculate Fargate costs, you can refer to our blog post on AWS Fargate pricing. To sum up, Fargate billing is based on:
- Number of ECS tasks you run
- Duration of each task
- vCPUs used for tasks (charged per hour)
- Memory used for tasks (charged per GB-hour)
While you pay a premium price with Fargate, it allows developers to focus on developing and managing applications. Users simply specify the resources needed for the task, and Fargate will launch the containers. Moreover, it improves security as applications are isolated by design.
What are trade-offs? Here, the trade-off can be limited control and customization, fewer features, and higher costs.
Fargate vs. EC2: It also brings us to the evergreen debate on Fargate vs. EC2. With EC2, you do not pay a premium price but pay for the whole instance regardless of how much of it is used by your containers. On the other hand, Fargate can better match the resource requirements of your containers. Both the compute options have their pros and cons and are best when deployed with their ideal use cases. For a better comparison between the two, check out our Fargate vs. EC2 pricing article.
Use cases for AWS Fargate
AWS Fargate can be ideal for:
- Workloads that need to scale fast
- Workloads that benefit from Fargate’s flexibility of right-sizing instances
- Large workloads that can be optimized for low overhead without hindering performance
- Small workloads with occasional bursts
- Tiny workloads such as small test environments where EC2 instances are too powerful and will not yield a good percentage of utilization
- Batch workloads or ones that consist of periodic tasks
ECS on AWS Outposts
Outposts is a fully managed service offered by AWS that extends its infrastructure, tools, APIs, and services to the customer’s premises. It enables organizations to build and run applications on-premise or on a hybrid infrastructure.
Pricing for ECS on AWS Outposts is simple and works similarly to deploying in the cloud. The ECS control plane is in the cloud, and your containers run on Outposts EC2 capacity at no additional charge. You only pay for the capacity your containers use. While Outposts offers various configuration options, it can incur costs for installation, upgrades, delivery, software patches, and infrastructure service maintenance. For detailed pricing, you can visit the AWS Outposts pricing page.
You can choose to host your ECS containers on Outposts if your use case requires keeping data on-premise or your applications have rigid low latency requirements. It can be expensive compared to other compute options but can prove great for specific workloads, as given below.
Use cases for AWS Outposts
AWS Outposts can be ideal for workloads:
- That require low latency compute
- That need data residency in a particular country, state, or municipality for regulatory, contractual, or information security reasons
- Legacy on-premise workloads that can be difficult to migrate or have latency-sensitive system dependencies
- That require local data processing
Amazon ECS Anywhere
It is another feature from AWS that enables managing and running workloads easily on customer-managed infrastructure. ECS Anywhere lets you benefit from the ease and simplicity of ECS, whether on-premise or in the cloud. It provides similar cluster management, workload scheduling, and monitoring experience as Amazon ECS.
There are no minimum charges or upfront costs for ECS Anywhere, but you pay for the running instances it manages. AWS charges $0.01025 per hour for each ECS Anywhere on-premises instance. The on-premise instances are customer-managed but registered with ECS clusters and run with ECS container agents. You can refer to the ECS Anywhere pricing page for detailed pricing and additional charges information.
Use cases for ECS Anywhere
It can be ideal for:
- Workloads that need to fulfill compliance, data gravity, and similar business requirements
- Containerizing existing on-premise workloads
- Containerized data processing workloads at edge locations
- On-premise video and ML processing workloads
- For running Windows container workloads across both on-premise and cloud environments
- Leveraging your existing infrastructure investments while also taking advantage of running workloads in the cloud
Once you have decided what launch type and pricing model suits your applications and business needs, you can draw strategies for optimizing ECS costs with the following techniques. For more tips on how to ideally build, operate, and manage containers, refer to our blog post on containerization best practices.
6 ways to reduce and optimize ECS costs
This section briefly talks about the cost optimization techniques. For detailed and insightful coverage of the techniques, refer to our article on ECS cost optimization.
Fargate and EC2 provide spot instances that allow you to run ECS tasks at significantly discounted rates (for example, 70% discount on the Fargate on-demand prices). When you launch tasks on spot instances, AWS runs them on the extra capacity available in the cloud. When it needs the capacity back, the tasks running on Spot instances will be interrupted and scale down. Thus, it can be ideal for fault-tolerant tasks.
AWS Savings Plans
These plans offer lower prices than on-demand pricing, provided that you commit to a specific amount of compute usage in $/hour for a one-year or three-year period. In addition, it is a relatively flexible pricing model as Savings Plans automatically apply to your resource usage and allocate them regardless of instance family, size, OS or tenancy, or region.
If your ECS services or clusters are running or scaling unnecessarily, it engages more resources and incurs higher costs. With AWS’s Auto Scaling feature, you can automatically increase or decrease the compute capacity for your containers. It ensures that your services run or scale only when necessary and help save costs.
Multiple Load Balancer
Container-based applications frequently need exposure to internal and external clients in the VPC. And if you maintain separate ECS services to serve traffic from both internal and external load balancers, it increases operational complexity and resource costs. But with ECS Multiple Load Balancer Target Group support, you can attach multiple target groups to a single ECS service running on EC2 or Fargate. Thus, it simplifies infrastructure code and reduces compute costs.
When applications are built with arbitrary configurations, they incur unnecessary compute costs. Right-sizing your containers can avoid overprovisioning for ECS tasks and help optimize resource usage and costs.
If you do not actively monitor resources used by your containers, you may not uncover or know about orphaned or idle resources that are incurring unnecessary charges. Tagging your ECS resources gives increased visibility into your workloads. In addition, it enables you to allocate costs optimally and quickly identify resources for your containers.
At Simform, we have helped businesses build cloud-native applications with a balance of performance and cost-efficiency. For example, we recently helped a recruitment platform modernize its architecture using Amazon ECS and AWS Fargate. It allowed us to delegate scalability and brought 600,000+ users in a day, increasing the traffic ten times the platform received earlier.
Simform is an Advanced AWS Consulting Partner helping organizations make the right and flexible tech choices for their business applications hosted in the cloud. Request a free consultation today with our cloud experts to build futuristic applications!