Cloud

AWS Fargate Explained: Serverless Containers Without Managing Servers

Learn what AWS Fargate is, how it compares to EC2 for containers, pricing considerations, and when to use Fargate vs ECS on EC2. Complete guide for decision-makers.

By InventiveHQ Team

AWS Fargate is a serverless compute engine that runs containers on Amazon ECS or EKS without you provisioning, patching, or scaling any EC2 instances — you specify a task's vCPU and memory, and AWS bills you per second (one-minute minimum) only while the task runs. The tradeoff is unit price: at $0.04048 per vCPU-hour and $0.004445 per GB-hour, a 2 vCPU / 4 GB service running 24/7 costs about $72/month on Fargate versus roughly $19/month on a Reserved t3.medium. Fargate wins on operational simplicity and on workloads that scale up and down; EC2 wins on steady, predictable, high-utilization compute.

That's the summary an AI Overview will give you. What it won't show you is the actual decision — so below you'll find an animated diagram of exactly which infrastructure layer AWS takes over, a side-by-side Fargate-vs-EC2 cost breakdown, the valid CPU/memory pairings that trip up first task definitions, and the four gotchas (cold starts, storage, networking, no SSH) that decide whether Fargate fits your workload.

What Is AWS Fargate?

AWS Fargate is a serverless compute engine for containers that works with both Amazon ECS (Elastic Container Service) and Amazon EKS (Elastic Kubernetes Service). With Fargate, you don't provision, configure, or scale virtual machines—AWS handles all infrastructure management.

You define your container requirements (CPU, memory, networking), and Fargate:

  • Provisions the right amount of compute
  • Runs your containers in isolation
  • Scales automatically based on demand
  • Patches and maintains the underlying infrastructure

Think of Fargate as "Lambda for containers"—you focus on your application, AWS handles everything else.

Fargate vs EC2: Key Differences

When running containers on AWS, you have two main options:

AspectFargateECS on EC2
Server managementNone (serverless)You manage EC2 instances
ScalingPer-task automatic scalingCluster + task scaling required
Pricing modelPay per vCPU/memory per secondPay for EC2 instances (running or not)
Startup time30-60 seconds typicallyFaster if capacity pre-provisioned
GPU supportLimitedFull GPU instance support
CustomizationStandard configurationsFull OS/instance customization
Cost at scaleHigher per-unit costLower with Reserved Instances
Choose it whenVariable/bursty traffic, small teams, no server opsSteady 24/7 load, GPUs, custom OS, Spot savings

How Fargate Pricing Works

Fargate pricing is based on the vCPU and memory resources your containerized application requests. You pay for what you use, billed per second with a one-minute minimum.

Current Pricing (US East - N. Virginia)

ResourcePrice per Hour
vCPU$0.04048
Memory (GB)$0.004445

Example Cost Calculation

For a container running with 0.5 vCPU and 1 GB memory for 24 hours:

vCPU cost: 0.5 × $0.04048 × 24 = $0.49
Memory cost: 1 × $0.004445 × 24 = $0.11
Total daily cost: $0.60
Monthly estimate: ~$18

Cost Comparison: Fargate vs EC2

For a workload requiring 2 vCPU and 4 GB memory running 24/7:

OptionMonthly CostNotes
Fargate~$72Pay exactly for resources used
t3.medium On-Demand~$302 vCPU, 4 GB - but pays even when idle
t3.medium Reserved (1yr)~$19Requires commitment

Key insight: Fargate costs more per unit but can save money for:

  • Variable workloads that scale up/down
  • Workloads that don't run 24/7
  • Teams without capacity to manage infrastructure

When to Use Fargate

Run your workload through this decision path before you pick a launch type:

Fargate vs EC2 decision flow A flowchart: if you need a GPU or custom kernel, use EC2. Otherwise, if the workload runs steady 24/7 at high utilization, EC2 with Reserved or Spot instances is cheaper. If the workload is variable, bursty, or interruptible, use Fargate — Fargate Spot for interruptible jobs. GPU or custom kernel/AMI? Yes Use EC2 No Steady 24/7, high, predictable utilization? Yes EC2 Reserved / Spot No Interruptible batch job? Yes Fargate Spot (-70%) No Fargate (on-demand) variable / bursty traffic

Fargate Is Ideal For:

  1. Microservices architectures - Each service scales independently
  2. Batch processing jobs - Pay only during processing
  3. Development and staging environments - No wasted capacity
  4. Teams without infrastructure expertise - Reduces operational burden
  5. Unpredictable traffic patterns - Automatic scaling without over-provisioning
  6. Quick deployments - No cluster capacity planning needed
Advertisement

Stick with EC2 When You Need:

  1. GPU workloads - Machine learning, video processing
  2. Persistent high utilization - 24/7 workloads benefit from Reserved Instances
  3. Custom AMIs or kernel configurations - Specialized OS requirements
  4. Maximum cost efficiency at scale - Large, predictable workloads
  5. Spot Instance savings - EC2 Spot can be 70-90% cheaper

Fargate Architecture

Here's how Fargate fits into the AWS container ecosystem. The green band is the boundary you own; everything below it AWS provisions, patches, and scales for you. On EC2 you'd own two more layers down — the instances and their OS.

The Fargate responsibility boundary A stack of layers from your application down to physical infrastructure. The top two layers (your app and the task definition) are managed by you; the Fargate compute layer and everything below are managed by AWS. A marker slides down the stack showing where your responsibility ends.

Who manages each layer

YOU MANAGE Your application Container image, code, dependencies ECS Task Definition / EKS Pod vCPU, memory, awsvpc networking, IAM task role AWS MANAGES AWS Fargate — serverless compute Isolated microVM per task, provisioning, autoscaling Managed instances & OS Patching, kernel, capacity — invisible to you Physical infrastructure Data centers, hardware, network fabric Your responsibility ends here — no servers to log into below this line

Each Fargate task runs in its own isolated environment with:

  • Dedicated kernel
  • No shared resources with other customers
  • Encrypted ephemeral storage

Getting Started with Fargate

Basic ECS Task Definition for Fargate

{
  "family": "my-fargate-app",
  "networkMode": "awsvpc",
  "requiresCompatibilities": ["FARGATE"],
  "cpu": "256",
  "memory": "512",
  "containerDefinitions": [
    {
      "name": "app",
      "image": "nginx:latest",
      "portMappings": [
        {
          "containerPort": 80,
          "protocol": "tcp"
        }
      ],
      "essential": true
    }
  ]
}

Key Configuration Points

  1. Network mode must be awsvpc - Each task gets its own ENI
  2. CPU and memory are at task level - Not individual containers
  3. Valid CPU/memory combinations exist - Not all combinations work

Supported CPU and Memory Combinations

CPU (vCPU)Memory Options (GB)
0.250.5, 1, 2
0.51, 2, 3, 4
12, 3, 4, 5, 6, 7, 8
24-16 (1 GB increments)
48-30 (1 GB increments)
816-60 (4 GB increments)
1632-120 (8 GB increments)

Fargate Spot: Reduce Costs by 70%

Fargate Spot runs tasks on spare AWS capacity at up to 70% discount. Like EC2 Spot Instances, tasks can be interrupted with a 2-minute warning.

Good for Fargate Spot:

  • Batch processing
  • CI/CD builds
  • Data transformation jobs
  • Any interruptible workload

Not for Fargate Spot:

  • User-facing web applications
  • Real-time APIs
  • Anything requiring high availability

Enable Fargate Spot in ECS

{
  "capacityProviderStrategy": [
    {
      "capacityProvider": "FARGATE_SPOT",
      "weight": 1,
      "base": 0
    },
    {
      "capacityProvider": "FARGATE",
      "weight": 1,
      "base": 1
    }
  ]
}

This configuration runs at least one task on regular Fargate and additional tasks on Spot.

Fargate with EKS vs ECS

Fargate works with both ECS and EKS. Here's how to choose:

FactorECS + FargateEKS + Fargate
Kubernetes expertiseNot requiredRequired
Multi-cloud portabilityAWS-specificKubernetes standard
Learning curveLowerHigher
EcosystemAWS-native toolsKubernetes ecosystem
CostJust FargateFargate + $0.10/hr EKS cluster

Recommendation: Use ECS + Fargate unless you specifically need Kubernetes features or are already invested in the Kubernetes ecosystem.

Common Fargate Gotchas

1. Cold Starts

Fargate tasks can take 30-60 seconds to start. For latency-sensitive applications:

  • Keep minimum task count > 0
  • Use Application Auto Scaling with target tracking
  • Consider ECS Service Connect for service discovery

2. Storage Limitations

Fargate provides 20 GB ephemeral storage by default (configurable up to 200 GB). For persistent storage:

  • Use EFS (Elastic File System) mounts
  • Store data in S3
  • Use external databases (RDS, DynamoDB)

3. Networking Complexity

Each Fargate task needs:

  • A VPC with subnets
  • Security groups
  • NAT Gateway for private subnet internet access

This adds cost and complexity compared to Lambda.

4. No SSH Access

You cannot SSH into Fargate tasks. For debugging:

  • Use ECS Exec for interactive sessions
  • Implement robust logging (CloudWatch Logs)
  • Add health check endpoints

Monitoring Fargate Workloads

Essential CloudWatch Metrics

MetricWhat It Tells You
CPUUtilizationContainer CPU usage percentage
MemoryUtilizationContainer memory usage percentage
RunningTaskCountNumber of tasks running
DesiredTaskCountTarget task count

Enable Container Insights

Container Insights provides deeper visibility:

aws ecs update-cluster-settings \
  --cluster my-cluster \
  --settings name=containerInsights,value=enabled

Migration Path: EC2 to Fargate

If you're currently on ECS with EC2, migration to Fargate is straightforward:

  1. Update task definition - Add "requiresCompatibilities": ["FARGATE"]
  2. Set network mode - Change to "networkMode": "awsvpc"
  3. Configure CPU/memory - Move from instance-level to task-level
  4. Update service - Change launch type to FARGATE
  5. Test in staging - Verify performance and costs

Final Thoughts

AWS Fargate removes infrastructure management from container deployments, letting teams focus on applications rather than servers. It's not always the cheapest option, but for teams without dedicated infrastructure expertise or workloads with variable demand, the operational simplicity often justifies the premium.

Start with Fargate for new projects, then optimize to EC2 if cost analysis shows significant savings potential. The migration path in either direction is manageable.

Frequently Asked Questions

Is AWS Fargate cheaper than EC2?

Not per unit of compute. A 2 vCPU / 4 GB task running 24/7 costs roughly $72/month on Fargate versus about $30/month for a t3.medium On-Demand instance and about $19/month with a 1-year Reserved Instance. Fargate saves money only when you would otherwise waste EC2 capacity — variable traffic, jobs that do not run around the clock, or teams whose engineering time is worth more than the compute premium.

What is the difference between AWS Fargate and Lambda?

Both are serverless, but Lambda runs short-lived functions (15-minute max, event-driven, packaged as code or a container image up to 10 GB) while Fargate runs full long-running containers with no execution time limit. Use Lambda for event handlers and glue code; use Fargate for services, APIs, and workloads that need to stay up or run longer than 15 minutes.

How long does a Fargate task take to start?

Typically 30-60 seconds from launch to a running container, because Fargate must provision an isolated microVM, attach an elastic network interface, and pull your image. For latency-sensitive services keep the minimum task count above zero and scale with Application Auto Scaling target tracking rather than scaling from zero.

Does Fargate support GPUs?

No. As of 2026 Fargate has no GPU support. Any machine-learning training, inference, or video-transcoding workload that needs a GPU must run on ECS or EKS backed by EC2 GPU instances (such as the g5 or p4 families).

How much persistent storage does a Fargate task get?

Each task gets 20 GB of encrypted ephemeral storage by default, configurable up to 200 GB. Ephemeral storage disappears when the task stops, so for anything that must survive a restart use an Amazon EFS mount, S3, or a managed database like RDS or DynamoDB.

Can you SSH into a Fargate container?

No — there is no host to SSH into. Use ECS Exec to open an interactive shell in a running container, ship logs to CloudWatch Logs, and add health-check endpoints for debugging. ECS Exec requires the SSM agent permissions on the task role and enableExecuteCommand set on the service.

What is Fargate Spot and when should I use it?

Fargate Spot runs tasks on spare AWS capacity at up to a 70% discount, but AWS can reclaim them with a 2-minute warning. It is ideal for interruptible work — batch jobs, CI/CD builds, data transformation — and a poor fit for user-facing web apps, real-time APIs, or anything that needs high availability.

Should I use ECS or EKS with Fargate?

Choose ECS + Fargate unless you specifically need Kubernetes. ECS has a lower learning curve and no control-plane fee; EKS adds a flat $0.10/hour (about $73/month) per cluster plus Kubernetes operational overhead, but gives you the portable Kubernetes API and its ecosystem. Pick EKS only if you already run Kubernetes or need multi-cloud portability.

Do all CPU and memory combinations work on Fargate?

No. CPU and memory are set at the task level and only specific pairings are valid. For example 0.25 vCPU allows 0.5, 1, or 2 GB; 1 vCPU allows 2-8 GB in 1 GB steps; 16 vCPU allows 32-120 GB in 8 GB steps. An invalid combination is rejected when you register the task definition.