Fargate Pricing: The Cost of Hosting an App in AWS Fargate

Fargate Pricing

As serverless computing becomes mainstream, more enterprises are embracing this technology in recent times. While implementing this serverless computing technology, Fargate pricing is something organizations should be careful of. This blog uncovers actual AWS Fargate pricing costs to host an app.

Table of contents

This blog is also been published on Medium

What is Fargate?

Fargate is a serverless compute engine that lets you deploy and manage apps, APIs, and microservices without the need to manage the underlying infrastructure. It also optimizes costs by only paying for the resources used. 

With Fargate, you simply package your app into containers, define Memory/CPU configuration and IAM policies, and run the application. Fargate makes scaling simple and easy. It works with Amazon Elastic Kubernetes Service (EKS) and Amazon Elastic Container Service (ECS). 

Fargate vs Lambda: A full comparison of the top serverless computing options.

Fargate Architecture

fargate architecture

Why Bother about Fargate Pricing?

Why bother about AWS Fargate pricing when it is a fully-managed serverless offering? You should! 

  • Because AWS handles the hardware of the container platform and not the container/pod size.
  • Because AWS automatically scales the number of containers/pods and not their sizes.
  • Because striking a balance between cost and performance is important, using the right-sized containers for the right tasks.
  • Because the application’s resource footprint, web server, computing platform, and libraries determine the right size of the containers/pods.
optimize your aws fargate budget with our devops services

AWS Fargate Pricing: Real Costs and Pricing Structure

AWS does not charge any upfront costs for Fargate. You only need to pay for the resources used. 

Primarily, Fargate pricing is based on the requested vCPU and memory capacities. However, other dimensions affect this price.

Fargate pricing is based on five independently configurable dimensions:

  1. vCPU
  2. Memory
  3. Operating System
  4. CPU Architecture
  5. System Resources

For instance, AWS charges $0.04048 per hour for one vCPU and $0.004445 per 1 GB per hour in the US East Ohio region for Linux /x86 architecture. When ARM CPU architecture is involved, the prices change to $0.03238 per vCPU per hour and $.00356 per GB per hour. 

For Windows / x86, the price is $0.09148 per vCPu per hour and $0.01005 per GB per hour. There’s also an additional OS license fee of $0.046 per vCPu per hour.

AWS Fargate Real costs and pricing structure

As you can see from the table above, the price of vCPU and memory varies with region, CPU architecture, and operating system. It is important to note that Windows OS and ARM CPU architecture options are available only for Amazon ECS and for selected regions. So, it’s important to consider all these aspects before calculating the Fargate cost.

Fargate Storage

Each ECS task hosted on the Fargate platform comes with a default ephemeral storage of 20 GiB. If a task needs additional storage, you can purchase ephemeral storage for up to 200 GiB per task. 

While the first 20 GiB ephemeral storage is free, every GiB after that value is charged based on the AWS region. For instance, AWS charges $0.000111 per GB per hour for Fargate ephemeral storage in the US East Ohio region. If a task uses 30 GB of ephemeral storage, only 10 GB is chargeable. 

AWS Fargate Pricing Examples

1) Small Apps

Consider a small app with concurrent users of less than 20 wherein each user consumes less than 50 MB over a period of 5 minutes. 

The first step is Capacity Planning: 

  1. Identify delta memory consumption for each user and multiply it with the concurrent users at the development stage using tools such as CloudWatch Application Insight.

Example: 20  concurrent users x 50 MB = 1000 MB

  1. Allocate buffer memory for peak requirements = 500 MB
  2. Allocate another 500 MB for container monitoring process consumption, such as Amazon CloudWatch, Grafana, or Prometheus. 
  3. The total memory comes to around 2 GB 
  4. Determine the corresponding vCPU value for 2 GB: 0.5 vCPU

For capacity planning, assign these values as a starting point:

Capacity ProviderFargate Capacity Providers
Min. task per service2
Max. task per service4
Memory per task2
vCPU per task0.5
Ephemeral Storage<20 GB per task

For two tasks with 1 GB memory and 0.25 vCPU each, the total comes down to 2 GB and 0.5 vCPU.

When you calculate the average monthly price:

  • No. of Tasks: 2 per day = (730 hours in a month / 24 hours in a day) = 60.83 per month
  • Task Duration: 5 minutes = 0.09 hours
  • vCPU Charges (0.5 vCPu)  = 60.83 tasks x 0.50 vCPU x 0.09 hours x 0.04048 USD per hour = 0.11 USD for vCPU hours
  • Memory Charges (2 GB): 60.83 tasks x 2.00 GB x 0.09 hours x 0.004445 USD per GB per hour = 0.05 USD for GB hours
  • Ephemeral Storage Charges: 20 GB – 20 GB (no additional charge) = 0.00 GB billable ephemeral storage per task

Fargate Cost (Monthly): 0.11 USD for vCPU hours + 0.05 USD for GB hours = 0.16 USD 

2) Medium-sized Apps

A medium-sized app has 50 concurrent users wherein each user consumes memory between 50MB and 80 MB over a period of 5 minutes.

Following the steps mentioned above, assign these values as a starting point:

Capacity ProviderFargate Capacity Providers
Min. task per service2
Max. task per service5
Memory per task50 concurrent users x 80 MB = 4 GB
Buffer capacity1 GB
Resources for container monitoring processes1 Gb
Total memory6 GB
vCPU per task2 vCPU

When you calculate the average monthly price:

  • No. of Tasks: 5 per day = (730 hours in a month / 24 hours in a day) = 152.08 per month
  • Task Duration: 5 minutes = 0.09 hours
  • vCPU Charges (2 vCPu)  = 152.08 tasks x 2 vCPU x 0.09 hours x 0.04048 USD per hour = 1.11 USD for vCPU hours
  • Memory Charges (6 GB): 152.08 tasks x 6 GB x 0.09 hours x 0.004445 USD per GB per hour = 0.37 USD for GB hours
  • Ephemeral Storage Charges: 30 GB – 20 GB (no additional charge) = 10.00 GB billable ephemeral storage per task
  • 152.08 tasks x 10.00 GB x 0.09 hours x 0.000111 USD per GB per hour = 0.02 USD for ephemeral storage GB hours

Fargate Cost (Monthly): 1.11 USD for vCPU hours + 0.37 USD for GB hours + 0.021 USD for ephemeral storage GB hours = 1.50 USD 

3) Large-sized Apps

A large-sized app has more than 100 concurrent users wherein each user consumes memory of more than 100 MB over a period of 5 minutes.

Following the steps mentioned above for small apps, assign these values as a starting point:

Capacity ProviderFargate Capacity Providers
Min. task per service2
Max. task per service5
Memory per task100 concurrent users x 100 MB = 10 GB
Buffer capacity3 GB
Resources for container monitoring processes3 GB
Total memory16 GB
vCPU per task4 vCPU

When you calculate the average monthly price:

  • No. of Tasks: 5 per day = (730 hours in a month / 24 hours in a day) = 152.08 per month
  • Task Duration: 5 minutes = 0.09 hours
  • vCPU Charges (4 vCPu)  = 152.08 tasks x 4 vCPU x 0.09 hours x 0.04048 USD per hour = 2.22 USD for vCPU hours
  • Memory Charges (16 GB): 152.08 tasks x 16 GB x 0.09 hours x 0.004445 USD per GB per hour = 0.97 USD for GB hours
  • Ephemeral Storage Charges: 50 GB – 20 GB (no additional charge) = 30.00 GB billable ephemeral storage per task
  • 152.08 tasks x 30.00 GB x 0.09 hours x 0.000111 USD per GB per hour = 0.05 USD for ephemeral storage GB hours

Fargate Cost (Monthly): 2.22 USD for vCPU hours + 0.97 USD for GB hours + 0.05 USD for ephemeral storage GB hours = 3.24 USD 

save money on your aws fargate costs with clickit

How To Reduce Costs in AWS Fargate?

Here are the top four ways to reduce costs in AWS Fargate:

1) AWS Savings Plan: Amazon Savings Plan helps you gain a discount of up to 72% on compute workloads regardless of the region, operating system, tenancy, size, and instance family. It automatically applies the discount to your EC2 instances and Fargate usage. However, the plan requires a 1-3 year commitment for a specified amount of usage (billed per hour). 

Once subscribed, the prices stay the same for the entire contract period, regardless of changing on-demand prices. There are different payment modes, such as No Upfront, Partial Upfront, and Full Upfront. 

Taking a cue from the AWS Cost Explorer in the form of recommendations, you can plan AWS Savings Plan while proactively managing the plan based on budget alerts and performance monitoring reports. When you run out of the subscription, the regular on-demand prices are automatically applied to your billing.

2) Fargate Spot Instances: AWS Fargate Spot is a useful feature for interruption-tolerant Amazon ECS tasks wherein you can gain a discount on Fargate pricing of up to 70%. On-demand and Spot instances look similar in most aspects but vary in two areas: the perGB and per vCPU costs vary up to 70%, and tasks are interruptible. 

The price is the same in all availability zones but varies throughout the day. AWS provisions spare capacity in the cloud, which is the reason for that jaw-dropping price. 

Please note that AWS removes these instances when it needs the capacity back with a 2-minute notification. As such, you should run interruption-tolerant tasks to enjoy this discount while not getting a hit on availability. 

It is important to terminate tasks gracefully. Tasks such as genome processing, image rendering, CI/CD, stateless web servers, and containerized workloads are a few examples that best suit the Fargate spot pricing model.

Fargate spot prices are charged per second but require a minimum of 1 minute usage. There are no upfront charges, and you only pay for the resources used. The billing starts when a container image starts getting downloaded till the termination of that task. 

3) Right-sizing Fargate tasks: When it comes to cost optimization, right-sizing Fargate tasks hold the key. Overprovisioning Fargate tasks is a common mistake that increases cloud costs.

When you choose smaller containers in more numbers, considering the lower costs, you should also consider the cold starts and performance issues. Alternately, when you choose large-sized containers in fewer numbers, it will result in resource wastage. Ideally, the tasks should use at least 85% of computing resources. 

To right-size Fargate tasks, 

  1. Check out the memory usage in the development stage. CloudWatch Application Insight gives you an idea of the memory utilization of an app. 
  2. Identify the concurrent users and multiply those values accordingly.
  3. Determine the corresponding vCPU values for that task.

AWS recommends the following computing configuration for effective capacity planning. 

CPU ConfigurationMemory ConfigurationSupported OS for Fargate
0.25 vCPU512 MB – 2 GBLinux
0.5 vCPU1 GB – 4 GB (1 GB Increments)Linux
1 vCPU2 GB – 8 GB (1 GB Increments)Windows, Linux
2 vCPU4 GB – 16 GB (1 GB Increments)Windows, Linux
4 vCPU8 GB – 30 GB (1 GB Increments)Windows, Linux
8 vCPU16 GB – 60 GB (4 GB Increments)Linux
16 vCPU32 GB – 120 GB (8 GB Increments)Linux
Source: Amazon ECS on AWS Fargate – Amazon Elastic Container Service
  1. Run load testing to evaluate the performance of that configuration for the assigned load.
  2. Fine-tune resource allocations.
  3. Define auto-scaling policies that balance cost and performance. As a best practice, check out the baseline performance of the application and its performance under load to rightly configure auto-scaling policies.

4) Tagging Resources: To gain greater visibility into workloads while optimizing costs, tag your AWS Fargate resources such as task definitions, clusters, container instances, services, etc. It will help you identify orphaned resources running unnoticed to reduce cloud waste. 

Tagging your resources facilitates fine-grained resource-level permissions and allows you to systematically manage the costs of workloads running across various teams, environments, and business units.

AWS ECS Costs – Without Fargate

AWS Elastic Container Service (ECS) offers two launch types, namely EC2 instance and Fargate. When you use an EC2 launch type, you’ll be paying a fixed price for the memory and CPU provisioned for that instance type, regardless of the percentage of resource usage. 

On the contrary, the Fargate cost is based on the resource usage for a single task, allowing you to right-size the instance.

AWS ECS Costs - Without Fargate

Let us take the popular m5.xlarge EC2 instance choosing the ‘Compute Savings Plan’ with a 1-year commitment and no upfront charges. It comes with a fixed configuration of 4 vCPU and 16 GB memory values.

  • Compute Savings Plans rate for m5.xlarge in the US East (Ohio) for one-year term and No Upfront is 0.141 USD
  • Hours in the commitment: 365 days * 24 hours * 1 year = 8760.0000 hours
  • Total Commitment: 0.141 USD * 8760 hours = 1235.1600 USD
  • Upfront: No Upfront (0% of 1235.16) = 0.0000 USD
  • Hourly cost for Compute Savings Plans = (Total Commitment – Upfront cost)/Hours in the term: (1235.16 – 0.00)/8760 = 0.1410 USD
  • Normalized Compute Savings Plans monthly price: (0.000000 USD / 12 months) + (0.141000 USD x 730 hours in a month) = 102.930000 USD

The Fargate monthly price for the same configuration (Always Active):

  • (4 vCPU  x 0.04048 USD per hour x  24 hours x 30 days) + 16 GB x 0.00445 USD per hour x 24 hours x 30 days = $167.78

It is important to note that Fargate pricing starts decreasing with the increase of resource idle time.

AWS EKS Costs – Standalone with no Fargate Service

While AWS ECS is free, and you only pay for the EC2 instances used, Amazon EKS comes with a charge of $0.10 per hour per EKS cluster you create. There are additional charges to compute and storage resources used by these clusters. It means you’ll incur an additional monthly fee of $74 on each cluster compared to ECS. 

However, EKS is a fully-managed Kubernetes service, and the ease with which you can manage container clusters outweighs the price difference. For instance, a single EKS cluster enables you to run multiple apps. 

Fargate vs ECS vs EKS: Pricing Comparison

Here is a comparison of ECS with EC2 launch type and Fargate launch type:

Fargate vs ECS vs EKS: Pricing Comparison

When comparing Fargate pricing with that of ECS or EKS, Fargate costs more for vCPU and GB resources. However, AWS meters RAM and CPU independently and doesn’t count the unused cluster capacity. So, the cluster reservation rate is making the difference here in terms of costs. 

fargate vs ecs/eks costs

Conclusion

If your ECS cluster utilization is 100%, you’ll save 20%-30% on costs compared to Fargate. Anything less than 80% will cost you more than Fargate pricing. However, consider the infrastructure management tasks such as configuring, running, patching, and securing hosted VMs. Autoscaling resources at the cluster and container level is another headache. 

With the right-sized Fargate configuration, you gain on costs and complexities of infrastructure management.

You might also enjoy: Top AWS Security Tools

FAQs

How do Graviton2 Processors affect Fargate Pricing?

Graviton is an ARM processor developed by Amazon. It was designed with the best price-performance for cloud workloads, and its processors run faster than x86 processors. 
Moreover, the vCPU and GB prices for Graviton2 processors are 20% cheaper than the x86 ones. However, Graviton2 processors are not available for the Windows platform. They only support Linux OS.

Is the Fargate Spot option available for Amazon Elastic Kubernetes Service (EKS)?

No. Fargate Spot is not available as a capacity provider for Amazon EKS workloads hosted on Fargate. Nevertheless, this feature is available for ECS workloads hosted on Fargate.

Can you combine Fargate and EC2 instances in the same cluster?

Yes. You can use both Fargate and EC2 instances in the same cluster. As a best practice, use Fargate for short-running tasks and EC2 instances for long-running tasks to gain Fargate’s cost advantage.

Subscribe

to our newsletter

Table of Contents

We Make DevOps Easier

Weekly DevOps Newsletter

Subscribe to our DevOps News

Subscribe to a monthly newsletter to receive the IT best practices, startup-related insights & emerging technologies.

Join hundreds of business leaders and entrepreneurs, who are part of our growing tech community.

We guarantee 100% privacy. Your information will not be shared.