AWS Fargate allows customers to run containerized workloads without managing underlying servers or infrastructure. Customers can choose either Amazon ECS or EKS as orchestration engines to run containers on Fargate. While AWS simplifies your life somewhat by not having to manage the underlying infrastructure, it comes at a premium. This post aims to show the pricing impact of using Fargate relative to a self-managed EC2 cluster.
How does AWS Fargate Pricing work?
AWS Fargate charges customers on two different compute dimensions: vCPU and GB of RAM. When you run containers on AWS Fargate you configure what amount of vCPU and GB of RAM you'd like available to your application in a Task Definition which is the configuration file AWS uses to run services on Fargate.
When you run a service in Fargate you can set the number of Tasks that run. So pricing is pretty simple arithmetic: the number of Tasks you run multiplied by the the amount of vCPU and GB assigned to each Task.
For simplicity's sake, we'll use us-east-1 for the pricing data in this blog post. The corresponding Fargate rates by dimension are below:
- per vCPU per hour: $0.04048
- per GB per hour: $0.004445
Pricing Example: Let's say you have a Task configured with 2 vCPUs and 1 GB of RAM. The cost of running one Task per hour would be (2 * $0.04048) + (1 * $0.004445) or $0.085405 per Task per hour.
Then let's say you have a Fargate service that runs 5 of these Tasks so your cost for the Fargate service would be 5 Tasks * $0.085405 per Task per hour or $0.427025.
How does this compare to self managed EC2?
ECS and EKS also allow you to manage your own underlying compute resources without using Fargate. One of the first questions that customers ask is: what is the premium I'm paying for Fargate relative to managing EC2 instances myself? To help answer this, we've come up with a few examples. We've taken a few popular EC2 instance types and priced out equivalent Fargate rates with the same amounts of vCPU and RAM. Again these examples are based off of pricing present in us-east-1:
c5.xlarge is a compute intensive EC2 instance with 4vCPUs and 8GB of RAM. It's hourly on-demand price is $0.17. A Fargate configuration with 4VCPUs and 8GB of RAM is ~$.19748 per hour. Fargate charges a ~16% premium relative to c5.xlarge instances.
m5.xlarge is a general purpose EC2 instance with 4vCPUs and 16GB of RAM. It's hourly on-demand price is $0.192. A Fargate configuration with 4VCPUs and 16GB of RAM is ~$.233 per hour. Fargate charges a ~21% premium relative to m5.xlarge instances.
t3.xlarge is a low cost burstable EC2 instance with 4vCPUs and 16GB of RAM. It's hourly on-demand price is $0.1664. A Fargate configuration with 4VCPUs and 16GB of RAM is ~$.233 per hour. Fargate charges a ~40% premium relative to t3.xlarge instances.
Important Note: Not all Fargate vCPUs are Created Equal
The other thing to note is that when you run a container on Fargate you don't actually know what kind of underlying EC2 instance you're going to be placed on. The pool of underlying compute that comprises Fargate seems to be a mix of different EC2 instances from what we can infer from spinning up large amount of containers and seeing different performance metrics. So not only are you paying a premium for Fargate, there is the potential you're paying a premium for significantly worse performance depending on your scheduling luck.
The operational time you save by using Fargate can sometimes be worth the premium you pay. However, we see transitioning from Fargate to EC2 as being not only a chance to potentially save money but also a chance to boost performance. Especially for more normalized compute patterns, managing your own cluster can be relatively easy. Hopefully this blog post gives you ways to think about this more deeply.