A Simple Breakdown of Amazon ECS Pricing

A Simple Breakdown of Amazon ECS Pricing

ยท

12 min read

ECS is a highly scalable, high-performance container orchestration service that makes it easy to run, stop, and manage Docker containers on a cluster of Amazon Elastic Compute Cloud (EC2) instances or with AWS Fargate. ECS is designed to simplify containerized application deployment by automating many of the tasks involved in managing and scaling container infrastructure.

Regardless of the project you're working on, if the infrastructure is hosted on AWS, you'll most likely find containerized core applications managed by Amazon Elastic Container Service (ECS) due to its maturity. Therefore, understanding the pricing structure of Amazon ECS is crucial for managing costs effectively.

This article will provide a simple breakdown of Amazon ECS pricing, compare it with other container orchestration platforms, discuss strategies for optimizing costs, and explore the AWS Free Tier for Amazon ECS.

A Deep-Dive into Pricing Calculation

We must separate the pricing calculation for ECS according to your chosen launch type, which can be Fargate, EC2, or Outposts. Furthermore, AWS also provides ECS Anywhere, enabling you to utilize ECS instance orchestration for your on-premises instances

ECS comes with different launch types that have significant different pricing.

Pricing for the Fargate Launch Type

With AWS Fargate, you pay for the amount of vCPU and memory resources that your containerized application requires. vCPU and memory resources are calculated from the moment your container images are retrieved until the Amazon ECS Task terminates, rounded up to the nearest second. A minimum charge of one minute applies.

Cost factors that determine your bill for ECS.

The primary factors affecting pricing are the configurations of your computing resources, which include:

  • Number of ECS tasks executed during the specified period

  • Execution duration of each task

  • Number of virtual CPUs (vCPUs) utilized for the task

  • Memory used for the task in GB

The prices vary depending on your chosen CPU architecture and operating system. Generally, Linux with ARM processors is the most affordable option, while running Windows on x86 is the most expensive.

Let's have a look at the current pricing, standing at June 2023, for us-east-1:

ResourceOS & CPU ArchitecturePrice per Hour
vCPU per hourLinux - ARM$0.03238
Linux - X86$0.04048
Windows - X86$0.09148 (+$0.046)
GB per hourLinux - ARM$0.00356
Linux - X86$0.004445
Windows - X86$0.01005

The additional charges for vCPU per hour for Windows result from OS license fees, which are also billed on an hourly basis.

If we rephrase this in terms of percentage differences using Linux and ARM as the baseline, we can see how significantly more expensive Linux and especially Windows on X86 are.

ResourceOS & CPU ArchitectureDifference to Linux/ARM
vCPU per hourLinux - X86+25%
Windows - X86+325% ๐Ÿ”ฅ
GB per hourLinux - X86+25%
Windows - X86+182% ๐Ÿ”ฅ

In summary, we can gather some simple insights about Fargate pricing based on the following comparisons:

  • If your application is compatible with ARM processors, utilize them as they are significantly more cost-effective.

  • Only use Windows if there is truly no other alternative.

Fargate Spot Pricing for Amazon ECS

By utilizing Fargate Spot, customers can execute Amazon ECS Tasks that can tolerate interruptions on available capacity, saving up to 70% off the usual Fargate cost.

The Spot price that is valid during the runtime of your Amazon ECS Tasks is what you pay with Fargate Spot. AWS Fargate sets Fargate Spot prices, which change gradually based on the long-term supply and demand trends for Fargate Spot capacity. You can check the current Spot price for vCPU-hour and GB-hour for each region on the AWS Fargate pricing page.

Please remember to use spot pricing only for interruptible tasks and not for workloads that require continuous execution, such as customer-facing web applications.

Pricing for EC2 Launch Type

There are no upfront charges for the Amazon EC2 launch type. You pay for AWS resources, such as Amazon EC2 instances or Amazon EBS volumes which you create to store and run your application. You only pay for what you use, as you use it; there are no minimum fees and no upfront commitments. EC2 usage is billed in a highly detailed manner, using one-second increments, with a minimum charge of 60 seconds.

Purchase Models

EC2 offers various purchase models with significantly different pricing:

  • On-Demand - offer hourly or second-based payment for computing capacity, freeing you from the expenses and complexities of hardware planning, purchasing, and maintenance, and converting significant fixed costs into smaller variable costs.

  • Savings Plans - a flexible pricing model that can reduce your bill by up to 72% compared to On-Demand prices, but it requires a commitment to a consistent amount of usage for a one or three-year term.

  • Spot Instances - as mentioned in the Fargate section, Spot Instances offer a discounted price (up to 90%) for unused compute capacity at AWS, suitable for workloads that can tolerate interruptions.

Dedicated or Reserved Capacity

When it comes to EC2 instances, AWS offers two options to ensure that you always have access to the computing capacity you need:

  • Dedicated Hosts - offer fully dedicated physical EC2 servers for your use, allowing you to reduce costs by utilizing existing server-bound software licenses and meeting compliance requirements.

  • On-Demand Capacity Reservations - enable you to reserve compute capacity for your EC2 instances in a specific Availability Zone, mitigating the risk of capacity constraints and ensuring access to EC2 capacity when needed.

As observed, compared to Fargate, the differences in pricing are significantly larger, and there are more options available to fine-tune your workloads to find the perfect balance between computing demands and costs.

AWS also provides its pricing calculator, allowing you to calculate your EC2 costs based on all relevant variables.

Free Tier

As part of the AWS Free Tier, you can begin using EC2 at no cost. This includes 750 hours of Linux and Windows t2.micro instances (or t3.micro in regions where t2.micro is unavailable) each month for one year.

This means you can operate a single instance for one year without incurring any costs.

Pricing AWS Outposts

AWS Outposts enables the use of native AWS services, infrastructure, and operating models in on-premises facilities, allowing the same AWS APIs, tools, and infrastructure used in the AWS Cloud to be used in AWS Outposts environments.

Amazon ECS on AWS Outposts is ideally suited for low-latency workloads that necessitate proximity to on-premises data and applications.

Pricing for AWS Anywhere

ECS Anywhere is an extension of Amazon ECS that enables launching and deploying containerized applications on your infrastructure (on-premises) with an in-region ECS control plane. This option is particularly beneficial if you have significant investments in your data center or specific compliance or regulatory obligations that require you to own and operate your infrastructure.

With ECS Anywhere, you pay a fixed rate of $0.01025 per hour for each instance managed by ECS. Of course, this is in addition to the costs of operating and maintaining your own infrastructure.

Additional Charges May Apply

It's important to note that in both cases, additional charges may apply for other AWS services used in conjunction with ECS and/or EC2, such as load balancers, data transfer fees, NAT gateways, EBS volumes, or CloudWatch log ingestion and storage.

It's always a good idea to review the AWS pricing documentation and estimate your costs or use the AWS cost calculator before deploying applications on ECS.

If you're running your containers within a private VPC and require a NAT gateway, this can be one of the most significant cost drivers. It's often criticized at AWS because the NAT-managed instances do not come with usage-based pricing (e.g., only based on transferred data) but are priced hourly based on data processing usage.

Strategies for Optimizing Cost

Conserving cloud resources is crucial, and there are multiple tips and tricks you can employ to achieve the optimal balance between savings and computing resources, depending on your requirements.

Using Spot Instances

As discussed before, spot instances offer a great saving potential but they should only be used for interruptable workloads.

The great thing here is that, in your service's auto-scaling policy, you can specify a certain number of tasks...

  • that should run at all times in on-demand mode and

  • the rest can run on spot instances, when available.

This way, you can maintain a balance between cost optimization and workload continuity.

Making Use of Auto-Scaling

To optimize costs in ECS and Fargate, auto-scaling policies can be utilized by fine-tuning the configuration based on the baseline performance of your application, ensuring that the cluster scales up only when necessary, and setting thresholds based on the specific utilization of each application, such as CPU or disk utilization.

Stopping Instances when they are not needed via Scheduled Scaling Policies

Scheduling instances is an effective way to reduce costs. For instance, if a system is utilized by employees, it is logical to shut it down during weekends or their off-hours. Another alternative is automating batch scheduling, operating instances based on the number of jobs required to run on them.

You can schedule ECS workloads using the scheduled scaling configuration, which is accessible in both ECS and Fargate.

Finding the Sweet Spot for the Container or Instance Size

To correctly size Fargate compute resources for an application, you can use CloudWatch metrics to monitor the application's resource utilization over time. By analyzing this data, you can determine the optimal amount of CPU and memory required to run your application efficiently.

To get started, you can create CloudWatch alarms to track CPU and memory usage for your Fargate tasks. These alarms can be set up to trigger notifications when usage exceeds a certain threshold, allowing you to take action before it impacts performance.

Once you have collected enough data, you can use CloudWatch dashboards to visualize trends in resource utilization and identify any patterns or anomalies. This information can be used to adjust the amount of CPU and memory allocated to your tasks, ensuring that you are not overprovisioning resources and incurring unnecessary costs.

Overall, using CloudWatch metrics to monitor Fargate resource utilization is a powerful tool for optimizing performance and reducing costs.

Leveraging Discounts

Expanding upon this concept is relatively simple: if you have a clear understanding that your project necessitates a certain level of computing resources for a minimum duration of one year, it is highly recommended to capitalize on the available compute savings plans discussed earlier. By doing so, you can secure substantial discounts on your overall cloud computing expenses.

These compute savings plans are designed to provide users with a cost-effective solution for long-term commitments, allowing them to enjoy significant savings as compared to on-demand pricing models. By accurately estimating your required resources and committing to a one-year or longer term, you can effectively optimize your resource allocation and significantly reduce your overall expenditure on cloud computing services.

Using AWS Cost Explorer and Cost Allocation Tags

Using AWS Cost Explorer, you can easily analyze your cost structure, identify primary cost drivers, and discover potential optimization areas by examining service, region, resource, or instance type details.

Using price allocation tags to explore the pricing structure of your acocunt.

Cost Explorer provides a significant feature that offers flexibility, which is the Cost Allocation Tags. These tags can be defined to measure costs at any level of granularity and can be structured and applied as desired. This tool is perfect for gaining detailed insights into your cost structure, allowing you to discover which specific sections of your infrastructure significantly impact your expenses, whether it's a component, sub-component, or a particular cluster of services.

Another great feature is the Usage Type filter that displays usage hours for ECS and Fargate, categorized by AWS region. To view Fargate hours in a specific region, simply type Fargate in the search box and include the appropriate filter, e.g. USE1-Fargate-vCPU-Hours:perCPU(Hrs) to display costs for the vCPU hours of your Fargate instances. You can also find your spending for spot instances which has a corresponding filter including the keyword SpotUsage.

General Tip: Use AWS Budgets

Spending limitations cannot be set for individual services or accounts, resulting in payment for all incurred costs. Many individuals avoid learning about cloud technology due to fear of unexpected expenses at the end of the month.

AWS Budgets allow you to establish billing alerts that notify you when specific thresholds are exceeded.

AWS Budgets can be utilized to create alerts for exceeding specific cost thresholds. Moreover, AWS offers cost projections for your account based on past and current usage, which can also be used to trigger budget notifications.

Overview about created budget alerts.

The alerts are not in real-time, even though the forecasts are updated at particular intervals. Nevertheless, you will be notified via email if your set spending limits are being surpassed or are on the verge of being surpassed.

Conclusion

In conclusion, understanding Amazon ECS pricing is crucial for effectively managing costs and optimizing resource utilization.

By choosing the right launch type, using spot instances, employing auto-scaling, scheduling workloads, and monitoring performance with CloudWatch, you can strike the perfect balance between cost efficiency and performance in your containerized applications.

Frequently Asked Questions

  1. What is Amazon ECS?
    Amazon ECS is a highly scalable, high-performance container orchestration service that makes it easy to run, stop, and manage Docker containers on a cluster of Amazon EC2 instances or with AWS Fargate.

  2. How is pricing calculated for the Fargate launch type?
    Fargate pricing is based on the amount of vCPU and memory resources that your containerized application requires. vCPU and memory resources are calculated from the moment your container images are retrieved until the Amazon ECS Task terminates, rounded up to the nearest second.

  3. What is Fargate Spot pricing and when should I use it?
    Fargate Spot pricing allows you to execute Amazon ECS Tasks that can tolerate interruptions on available capacity, saving up to 70% off the usual Fargate cost. It's suitable for interruptible tasks and not for workloads that require continuous execution.

  4. How does pricing work for the EC2 launch type?
    For the EC2 launch type, there are no upfront charges. You pay for AWS resources, such as EC2 instances or EBS volumes, that you create to store and run your application. EC2 usage is billed in one-second increments, with a minimum charge of 60 seconds.

  5. What are some strategies for optimizing costs in Amazon ECS?
    Optimizing costs in Amazon ECS can be achieved by using spot instances, employing auto-scaling, scheduling workloads, and monitoring performance with CloudWatch to find the optimal balance between cost efficiency and performance.

If you found this article insightful, here are some related articles that may be interesting for you:

ย