Answers: <p><strong>Update 12/05/2020:</strong> Fargate prices have been <strong>greatly reduced</strong> over the last months and are now <strong>comparable with EC2 prices</strong> for the same CPU / RAM configurations. That makes Fargate a valid option for 24x7 workloads. </p>
  
  <hr>
  
  <p><em>Originally written in 2018 - no longer correct!</em></p>
  
  <p>Fargate is more expensive than EC2 for the same vCPU/RAM amount.</p>
  
  <p>For example:</p>
  
  <ul>
  <li><a href="https://aws.amazon.com/ec2/pricing/on-demand/" rel="nofollow noreferrer">m5.large</a> (2 vCPU, 8 GB RAM) costs $0.096/hr which is ca $69.12/month</li>
  <li><a href="https://aws.amazon.com/fargate/pricing/" rel="nofollow noreferrer">Fargate container</a> with 2vCPU and 8 GB RAM costs $0.2028/hr or $146.02/month</li>
  </ul>
  
  <p>If you want to run your container 24x7 you'll be much better off running it on an EC2 instance.</p>
  
  <p>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.</p>
  
  <p>With Fargate you pay premium for the flexibility. </p>
  
  <p>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. </p>
  
  <p>Here Fargate works great for us. I wouldn't use it for an always-on service though.</p>
  
  <p>Hope that helps :)</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-05-11T15:41:24.177Z
Answers: Just to note, while this was a big factor when it was written, Fargate pricing has since been cut significantly. https://aws.amazon.com/blogs/compute/aws-fargate-price-reduction-up-to-50/ 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.
Answers: NoelLH
Answers: CC BY-SA 4.0
Answers: 2020-05-11T20:49:25.667Z
Answers: @NoelLH Very true, thanks for pointing that out. I have updated the answer.
Answers: MLu
Answers: CC BY-SA 4.0
Answers: 2018-09-29T00:06:38.750Z
Answers: 2020-05-11T21:09:49.310Z
Answers: 2020-05-11T21:09:49.310Z
Answers: MLu
Body: <p>Amazon offers the option of launching their container management services <code>ECS</code> and <code>EKS</code> in two modes: <code>EC2</code> and <code>Fargate</code>.</p>
  
  <p>In the former, normal VMs (<code>EC2</code> instances) are used and <code>ECS</code> or <code>EKS</code> (depending on the selection) clusters are created.</p>
  
  <p>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.</p>
  
  <p>Given that <code>Fargate</code> 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 <code>EC2</code> - based solution.</p>
  
Tags: <amazon-web-services><amazon-ec2><amazon-ecs>
Title: AWS ECS/EKS: EC2 vs Fargate mode
UserDisplayName: pkaramol
ThreadText: # AWS ECS/EKS: EC2 vs Fargate mode
  
  (Asked by: username_0 on 2018-08-23)
  
  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.
  
  **Tags:** amazon-web-services, amazon-ec2, amazon-ecs
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-09-29. Score: 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](https://aws.amazon.com/ec2/pricing/on-demand/) (2 vCPU, 8 GB RAM) costs $0.096/hr which is ca $69.12/month
  * [Fargate container](https://aws.amazon.com/fargate/pricing/) 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 :)
  
  > **Comments:**
  > **username_2**: Just to note, while this was a big factor when it was written, Fargate pricing has since been cut significantly. https://aws.amazon.com/blogs/compute/aws-fargate-price-reduction-up-to-50/ 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.  
  > **username_1**: @username_2 Very true, thanks for pointing that out. I have updated the answer.  
  
  ---
  
  