2018-10-06 - Is AWS Fargate expensive?

I am currently working on putting my containers into Fargate, but what does it actually cost and is it better than using EC2 instances? (And what does Azure ACI cost.. perhaps another future article?)

https://aws.amazon.com/fargate/pricing/

Fargate pricing
vCPU: $0.005 per vCPU-s
Memory: $0.00127 per GB-s 

ECS Fargate containers is configure by specifying CPU and MEMORY:

https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_TaskDefinition.html

CPU:

cpu
The number of cpu units used by the task. If using the EC2 launch type, this field is optional and any value can be used. If using the Fargate launch type, this field is required and you must use one of the following values, which determines your range of valid values for the memory parameter:

256 (.25 vCPU) - Available memory values: 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB)
512 (.5 vCPU) - Available memory values: 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB)
1024 (1 vCPU) - Available memory values: 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB)
2048 (2 vCPU) - Available memory values: Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB)
4096 (4 vCPU) - Available memory values: Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB)

MEMORY:

memory
The amount (in MiB) of memory used by the task. If using the EC2 launch type, this field is optional and any value can be used. If using the Fargate launch type, this field is required and you must use one of the following values, which determines your range of valid values for the cpu parameter:

512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Available cpu values: 256 (.25 vCPU)
1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available cpu values: 512 (.5 vCPU)
2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB) - Available cpu values: 1024 (1 vCPU)
Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Available cpu values: 2048 (2 vCPU)
Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available cpu values: 4096 (4 vCPU)


I created a simple overview of pricing and the different configurations:

https://docs.google.com/spreadsheets/d/15e3f-4v3iCzUXT2IHpE6nMlIV-RyWJOBKhB_w0qBP-M/edit?usp=sharing

With this overview it's easier to see what is the cost.

Example pricing

Container setup with the smallest configuration:

25 Containers running on  ".25 vCPU" and "0.5 GB memory" has a monthly cost at == 285$

The problem is the memory usage. 512 MB is not always enough for running some containers.

The next problem is that 25 running containers is just the smallest number of containers. We usually have about 100 running in DEV, 25 in TEST, and 50 in PROD.

The cost is now up at 175 running containers costing a whooping 2394$. iiiiik.

The same workload on "On-Demand Pricing EC2 instances" can run on about 3 "t2.medium" and 10 "t2.small" instances, and that cost about 396$.

So, with Fargate we have at least an 6x cost increase. Wow.

And we even loose the dynamic memory allocation of containers running in a EC2 instance. But we gain the power of declarative server setup and serverless containers.

And how does this compare to Azure ACI?

https://azure.microsoft.com/en-us/pricing/details/container-instances/

Azure ACI pricing
Memory: $0.000005 per GB-s 
vCPU: $0.000014 per vCPU-s

Comparing Fargate and ACI

https://docs.google.com/spreadsheets/d/15e3f-4v3iCzUXT2IHpE6nMlIV-RyWJOBKhB_w0qBP-M/edit?usp=sharing

Cloud175 containers
AWS Fargate2394$
Azure ACI2722$

Which is basically the same in pricing, but ACI does not have an Container Orchestrator like AWS ECS. ECS has declarative setup and desired state. This basically means that Azure ACI is useless in comparison. Noone configures all of their containers manually. Azure ACI makes more sense when used with Azure AKS, but not alone.