AWS ECS/EKS: EC2 vs Fargate mode
Update 12/05/2020: Fargate prices have been greatly reduced over the last months and are now comparable with EC2 prices for the same CPU / RAM configurations. That makes Fargate a valid option for 24x7 workloads. 



Originally written in 2018 - no longer correct!

Fargate is more expensive than EC2 for the same vCPU/RAM amount.

For example:


m5.large (2 vCPU, 8 GB RAM) costs $0.096/hr which is ca $69.12/month
Fargate container with 2vCPU and 8 GB RAM costs $0.2028/hr or $146.02/month


If you want to run your container 24x7 you'll be much better off running it on an EC2 instance.

However if your containers only run briefly to complete a task and then exit, or if they scale up and down based on demand it will be much easier for you to run them in Fargate - you won't need to scale up and down the underlying EC2 cluster to support the load.

With Fargate you pay premium for the flexibility. 

In many cases it works out better to run on Fargate even if it's more expensive - we spin up batches of hundreds of containers at a time a couple times per day for some processing and each container runs for only about 10 minutes. If we had to scale up the EC2/ECS cluster before each run, wait for it to settle, deal with the failures, then run our batch job and then scale down again the overhead would be quite high and our batch processing would take much longer. 

Here Fargate works great for us. I wouldn't use it for an always-on service though.

Hope that helps :)