AWS Knowledge

Understanding AWS Fargate Pricing and Costs

Stuart Lundberg

Sep 23, 2023

    Table of contents will appear here.
    Table of contents will appear here.
    Table of contents will appear here.

Understanding AWS Fargate Pricing

AWS Fargate is an excellent alternative to EC2 Auto Scaling Groups when running containerized applications. It lets you forget about infrastructure management, and focus on developing and maintaining your applications. Let's dive deeper into how it enables you to deploy containers effortlessly so you can cut your AWS bill and save your time.

What is AWS Fargate

AWS Fargate is Amazon Web Service's serverless compute engine for containers. It abstracts away all the responsibilities of provisioning, configuring and scaling clusters of virtual machines where your containers will run. Amazon EC2 does a good job of simplifying management of clusters with EC2 Auto Scaling Groups, but Fargate makes this completely effortless. This lets you deploy containers in a truly serverless way.

How does AWS Fargate work?

Fargate acts as a capacity provider for both Elastic Container Service (ECS) and Elastic Kubernetes Service (EKS). When you create an ECS or EKS cluster, you can select as capacity providers an Auto Scaling Group of EC2 instances, where you manage the instances yourself, or Fargate, where everything is managed for you.

AWS Fargate for ECS

When using Fargate with ECS, you define your application as ECS Tasks Definitions, and ECS handles creating instances of those Task Definitions, called Tasks. It launches those Tasks in Fargate, for a completely managed and serverless container experience.


These are the core elements of ECS:

  • Task Definitions: A Task Definition acts like a template for the containers your application will run. You specify the container image to use, CPU and memory configurations, network modes, and other essential parameters. Then, ECS uses your Task Definition to launch Tasks.

  • Tasks and Services: Once you have your Task Definitions, you decide how many Tasks you want to run with those specifications, and create a Service. The Service will use the Task Definition to create Tasks. A Service also has a deployment type, which can be EC2 or Fargate. In order to select EC2, you need an Auto Scaling Group associated with the ECS cluster, and you need to put time and effort into maintaining that Auto Scaling Group. Selecting Fargate will let ECS deploy the service and its tasks in a serverless way, where they'll launch and scale faster, and with no maintenance efforts from you.

AWS Fargate for EKS

EKS is a managed service that provides you with an already-configured Kubernetes cluster and control plane. Kubernetes runs your application in Nodes, which are configured for the cluster. With Fargate, you don't need to worry about configuring Nodes anymore.

These are the core elements of a Kubernetes cluster on EKS with Fargate:

  • Pods: A Pod is essentially a container running your application and serving your users. It contains some configurations, like how much CPU and memory it's assigned, the maximum it can request, auxiliary (sidecar) containers, and some networking configurations. You don't typically create Pods manually, but instead configure a Deployment to create the necessary Pods for you.

  • Deployments and ReplicaSets: A Deployment is a specification of how an application or service will be deployed. It includes how many replicas of it need to be running, what container image to use, and the rules to scale the deployment. Behind the scenes, a Deployment creates a ReplicaSet, which in turn creates and maintains the necessary Pods.

  • Nodes: A Node is a computer server (physical or virtual) where Kubernetes will place your Pods. If you use EC2, each EC2 instance will be a Node in your Kubernetes cluster. If you use Fargate, you're abstracted away from the need to manage Nodes at all. Fargate will automatically create and destroy them much faster than EC2, and register them with EKS as needed.

  • Cluster Autoscaling: Autoscaling a Kubernetes cluster is a bit more complex than a single EC2 Auto Scaling Group. For that reason, Kubernetes comes with its own scaling algorithm: Cluster Autoscaler. However, different algorithms have been created, with some like Karpenter performing better than the default on most use cases. Selecting the right cluster scaling algorithm is another thing that you forget about when using Fargate. Fargate's integration with EKS lets it scale faster than EC2 with any algorithm.

AWS Fargate Pricing Explained

Fargate's pricing is based on the vCPU and memory your Tasks or Pods use. You're billed from the time they start to download the container image until the ECS Task or EKS Pod terminates, rounded up to the nearest second. Different OSs and architectures have different prices.

Fargate for Linux (x86) Pricing

The price is the following:

  • $0.04048 per vCPU per hour

  • $0.004445 per GB of memory per hour

For example, an ECS Task or EKS Pod with 1 vCPU and 4 GB of memory running on Fargate for Linux (x86) will cost you $0.05826 per hour that it's running. If you ran 2 of them constantly, that would be $83.89/month.

Fargate for Linux (ARM) Pricing

The price is the following:

  • $0.03238 per vCPU per hour

  • $0.00356 per GB of memory per hour

For example, an ECS Task or EKS Pod with 1 vCPU and 4 GB of memory running on Fargate for Linux (ARM) will cost you $0.04662 per hour that it's running. If you ran 2 of them constantly, that would be $64.13/month.

Fargate for Windows Pricing

Given the licensing costs associated with Windows, the pricing for Fargate tasks and pods on Windows is higher. These are the prices:

  • $0.09148 per vCPU per hour for compute capacity

  • $0.046 per vCPU per hour for OS license fee

  • $0.01005 per GB of memory per hour

For example, an ECS Task or EKS Pod with 1 vCPU and 4 GB of memory running on Fargate for Windows will cost you $0.17768 per hour that it's running. If you ran 2 of them constantly, that would be $255.85/month.

AWS Fargate Spot

With Fargate Spot you can save up to 70% when running ECS Tasks that tolerate interruptions. It works just like EC2 Spot Instances, and it's only available for Linux (x86), and only for ECS. With Fargate Spot, Fargate sets the Spot price and adjusts it gradually based on long-term trends in supply and demand (meaning the price can increase!). You pay the Spot price that is in effect for the period your ECS Tasks are running.

These are the prices for Fargate Spot in US East (N. Virginia) as of August 30, 2023:

  • $0.01320519 per vCPU per hour

  • $0.00145003 per GB of memory per hour

For example, an ECS Task or EKS Pod with 1 vCPU and 4 GB of memory running on Fargate Spot will cost you $0.01900531 per hour that it's running. If you ran 2 of them constantly, that would be $27.36/month.

AWS Fargate Pricing Example

Let's go through a more realistic example. We're running an application on ECS, where our Tasks each consume 1 vCPU and 4 GB of memory. We need a baseline of 1 task constantly running. Our application scales to 2 tasks for an average of 3 hours every day, and to 3 tasks for an average of 1 hour every day:

  • For 20 hours a day, we need 1 task.

  • For 3 hours a day, we need 2 tasks.

  • For 1 hour a day, we need 3 tasks.

The cost for one task with 1 vCPU and 4 GB of memory running on Linux (x86) is:

1 * $0.04048 + 4 * $0.004445 = $0.05826 per hour

With our requirements, we'll be paying per month:

(20 * 1 * $0.05826 + 3 * 2 * $0.05826 + 1 * 3 * $0.05826) * 30 = $50.68/month

How to Optimize AWS Fargate Costs

Let's take our example from above, and go through some options we can analyze to optimize costs.

Right-Size Tasks or Pods

We probably set 1 vCPU and 4 GB of memory as an initial guess. Monitoring and performance testing might lead us to conclude that our application can function well with 1 vCPU and 3 GB of memory. Let's run the numbers:

The cost for one task with 1 vCPU and 3 GB of memory running on Linux (x86) is:

1 * $0.04048 + 3 * $0.004445 = $0.053815 per hour

With our requirements, we'll be paying $46.81/month. We just reduced our costs by 7%!

Choose The Right OS and Architecture

Sometimes there's no way to avoid using Windows or Linux (x86). But whenever possible, prefer Linux (ARM). Let's run the numbers:

The cost for one task with 1 vCPU and 3 GB of memory running on Linux (ARM) is:

1 * $0.03238 + 3 * $0.00356 = $0.04306 per hour

With our requirements, we'll be paying $37.46/month. We just reduced our costs by an additional 26% of the original cost!

Purchase Compute Savings Plans

Savings Plans are commitments that you can purchase, where you commit to a certain usage, either with upfront payment or monthly payments, and receive that capacity at a discounted price. A Compute Savings Plan 1-year commitment with no upfront pricing will save you 21% on both compute and memory costs, for Linux (ARM) tasks.

You can read our guide to understand what Savings Plans are and how they can help you reduce costs.

Use Pump to Reduce AWS Fargate Costs

Pump uses AI and group buying to select the most optimal pricing options for several AWS services, including AWS Fargate. This leads to 60% savings in your AWS bill, with no engineering intervention required. Pump is entirely free to you.

Pump is able to reduce costs in 12 AWS services, including AWS Fargate. This lets us achieve for startups the same discounts that big tech has, without extra engineering hours, and without paying a fee for the savings.

Conclusion

AWS Fargate lets you run containers on AWS ECS and AWS EKS without needing to manage compute infrastructure. It offers a serverless experience for ECS and EKS clusters, letting you abstract away from managing fleets of EC2 instances, and focus on developing your application. Understanding the details in how it's priced can lead to a significant reduction in your compute costs. Pump can help you reduce your Fargate costs by up to 60%, with our advanced AI and automated purchase of Compute Savings Plans through group buying.

1390 Market Street, San Francisco, CA 94102

Made with

in San Francisco, CA

© All rights reserved. Pump Billing, Inc.

1390 Market Street, San Francisco, CA 94102

Made with

in San Francisco, CA

© All rights reserved. Pump Billing, Inc.

1390 Market Street, San Francisco, CA 94102

Made with

in San Francisco, CA

© All rights reserved. Pump Billing, Inc.