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.
This blog is also been published on Medium
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.
Why bother about AWS Fargate pricing when it is a fully-managed serverless offering? You should!
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:
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.
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.
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:
Example: 20 concurrent users x 50 MB = 1000 MB
For capacity planning, assign these values as a starting point:
Capacity Provider | Fargate Capacity Providers |
Min. task per service | 2 |
Max. task per service | 4 |
Memory per task | 2 |
vCPU per task | 0.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:
Fargate Cost (Monthly): 0.11 USD for vCPU hours + 0.05 USD for GB hours = 0.16 USD
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 Provider | Fargate Capacity Providers |
Min. task per service | 2 |
Max. task per service | 5 |
Memory per task | 50 concurrent users x 80 MB = 4 GB |
Buffer capacity | 1 GB |
Resources for container monitoring processes | 1 Gb |
Total memory | 6 GB |
vCPU per task | 2 vCPU |
When you calculate the average monthly price:
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
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 Provider | Fargate Capacity Providers |
Min. task per service | 2 |
Max. task per service | 5 |
Memory per task | 100 concurrent users x 100 MB = 10 GB |
Buffer capacity | 3 GB |
Resources for container monitoring processes | 3 GB |
Total memory | 16 GB |
vCPU per task | 4 vCPU |
When you calculate the average monthly price:
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
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,
AWS recommends the following computing configuration for effective capacity planning.
CPU Configuration | Memory Configuration | Supported OS for Fargate |
0.25 vCPU | 512 MB – 2 GB | Linux |
0.5 vCPU | 1 GB – 4 GB (1 GB Increments) | Linux |
1 vCPU | 2 GB – 8 GB (1 GB Increments) | Windows, Linux |
2 vCPU | 4 GB – 16 GB (1 GB Increments) | Windows, Linux |
4 vCPU | 8 GB – 30 GB (1 GB Increments) | Windows, Linux |
8 vCPU | 16 GB – 60 GB (4 GB Increments) | Linux |
16 vCPU | 32 GB – 120 GB (8 GB Increments) | Linux |
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 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.
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.
The Fargate monthly price for the same configuration (Always Active):
It is important to note that Fargate pricing starts decreasing with the increase of resource idle time.
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.
Here is a comparison of ECS with EC2 launch type and Fargate launch type:
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.
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
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.
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.
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.
Have you ever wondered how businesses easily process enormous volumes of data, derive valuable insights,…
Discover the steps for developing cloud applications, from costs to cloud app deployment
Imagine launching your product with just the core features, getting honest user feedback, and then…
When a tight deadline is non-negotiable, every second counts! Here’s how we developed and launched…
You may have considered hiring a nearshore software development company or services, but you still have doubts…
End-to-end project management goes as far back as you can remember. Every project in history, even…