7

Amazon offers the option of launching their container management services ECS and EKS in two modes: EC2 and Fargate.

In the former, normal VMs (EC2 instances) are used and ECS or EKS (depending on the selection) clusters are created.

In the later, there is no concept of vm/instance present; you just have to deal with the containers and plan their capacity so that the system knows what memory/cpu needs you have.

Given that Fargate apparently accounts for a (far?) more cost-efficient solution given that you are charged only for the resources' consumption of your containers, I would like to know what are the benefits (or example use cases) where anyone would like to go with the EC2 - based solution.

6

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 :)

| improve this answer | |
  • Just to note, while this was a big factor when it was written, Fargate pricing has since been cut significantly. aws.amazon.com/blogs/compute/… The impact will vary depending on your CPU/memory but it is now normally only slightly more expensive than EC2, assuming you use 100% of your EC2 capacity. – NoelLH May 11 at 15:41
  • @NoelLH Very true, thanks for pointing that out. I have updated the answer. – MLu May 11 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.