CloudConsole

Fargate vs EC2 for Amazon ECS

Updated 17 November 2026 · How we write and check guides

Short answer

Use Fargate by default for ECS services: you pay per task for the vCPU, memory and storage you request and never patch a host. Use EC2 capacity (or ECS Managed Instances) when you need GPUs, privileged containers, specific instance types, or when steady, well-packed workloads make paying per instance cheaper than paying per task.

Fargate vs EC2 for Amazon ECS: deciding factors You pay for, Host management, Task sizes, GPU, privileged, custom kernels…
The deciding factors from this page's comparison table, and the cases where each option wins.

Fargate vs EC2 side by side

FactorFargateEC2 capacity
You pay forvCPU, memory and ephemeral storage requested per task, per second, one-minute minimum (Linux)The instances, whether tasks fill them or not
Host managementNoneAMIs, patching, agent updates, scaling the Auto Scaling group
Task sizesFixed combinations from 0.25 vCPU / 512 MiB up to 16 vCPU / 120 GB, plus 32 vCPU optionsAnything that fits the instance
GPU, privileged, custom kernelsNot supported (gpu and privileged are invalid)Supported
Networkingawsvpc only: one ENI per taskawsvpc, bridge or host
Storage20 GB ephemeral included, up to 200 GB; EFS and EBS volumesInstance disks, EBS, EFS, Docker volumes
SpotFargate Spot capacity provider, two-minute warningEC2 Spot through Auto Scaling groups
Commitment discountsCompute Savings PlansCompute or EC2 Instance Savings Plans, Reserved Instances

When Fargate wins

  • Services that scale up and down. You stop paying the moment a task stops; there is no half-empty instance waiting for the scale-in cooldown.
  • Small teams. Not owning AMIs, the ECS agent or instance draining removes a whole class of 3 a.m. pages.
  • Isolation. Each task gets its own kernel boundary and ENI, so security groups apply per task.
  • Batch and scheduled jobs that run for minutes, where per-second billing beats keeping instances warm.

Fargate Spot runs interruption-tolerant tasks at a discount; ECS sends SIGTERM with a two-minute warning, so handle the signal and drain work.

When EC2 wins

  • You need GPUs, privileged mode, extra Linux capabilities beyond CAP_SYS_PTRACE, or host networking.
  • Steady, predictable services you can bin-pack densely. If tasks fill instances well, paying per instance is often cheaper than Fargate's per-task rate. Check your real utilisation before assuming this.
  • You want a specific instance family, local NVMe, or a capacity reservation.
  • You run daemon tasks (log shippers, agents) on every host; the daemon scheduling strategy needs EC2.

A middle option now exists: ECS Managed Instances. AWS provisions, patches and scales the EC2 instances for you and charges a management fee on top of the instance price, while you keep instance-type choice and GPUs.

Switching capacity type

Use capacity providers rather than launch types. A service created with the Fargate launch type cannot be updated straight to the EC2 launch type, but it can move to an Auto Scaling group capacity provider (and back) with UpdateService, provided the task definition lists the target in requiresCompatibilities.

Before moving to Fargate, check the task definition for parameters Fargate rejects (links, dockerVolumeConfiguration, privileged, gpu) and pick a valid CPU and memory pair. A mixed strategy is also possible: a Fargate base with Fargate Spot on top for burst.

Common wrong reasons

  • "EC2 is always cheaper." Only if you keep instances full. Idle headroom, the scale-in lag and the hours spent patching often erase the gap.
  • "Fargate is slow to start." Image size dominates start time on both. Smaller images and a nearby registry help more than switching capacity.
  • "Fargate means no networking to plan." Every task takes an IP address from your subnet. Large services need large subnets.

Questions

Is Fargate more expensive than EC2?

Per vCPU-hour, Fargate usually costs more than a fully used instance, but you pay only for what each task requests and only while it runs. For spiky or small workloads Fargate is often cheaper overall.

Can one ECS cluster use both Fargate and EC2?

Yes. A cluster can have Fargate, Fargate Spot, Auto Scaling group and Managed Instances capacity providers, although one capacity provider strategy cannot mix the types.

Does Fargate support GPUs?

No. The gpu task definition parameter is not valid on Fargate. Use EC2 capacity or ECS Managed Instances for GPU workloads.

When this happens away from your desk

On Fargate there is no host to log in to when a task dies, so the stopped reason and the container logs are all you have; on EC2 you may also be chasing a full disk or a stuck agent. CloudConsole is being built to show ECS alarms, logs and resources on a phone with production guardrails.

About the app → · Download on the App Store

Sources