AWS Fargate: Serverless Containers Without the Kubernetes Complexity

TL;DR

AWS Fargate removes the need to manage EC2 instances for your containers. You define CPU/memory, AWS runs the infrastructure. It’s the sweet spot between Lambda’s limitations and EKS’s complexity. Best for: long-running containerized services, microservices that need more than 15 minutes, and teams that want Kubernetes features without node management. The catch: higher per-hour cost than EC2, cold starts of 30-60 seconds, and no GPU support.


What Is It?

Fargate is a serverless compute engine for containers that works with Amazon ECS and EKS. You specify CPU and memory requirements; AWS provisions and manages the underlying infrastructure.

The Problem It Solves

Traditional ECS/EKS:

You manage: EC2 instances → OS patching → Capacity planning → Auto Scaling Groups

With Fargate:

You manage: Container definition → Fargate provisions → AWS manages infrastructure

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    Your Container Task                       │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐       │
│  │   App        │  │   Sidecar    │  │   Logging    │       │
│  │   Container  │  │   (proxy)    │  │   Agent      │       │
│  └──────────────┘  └──────────────┘  └──────────────┘       │
│                                                              │
│  CPU: 1 vCPU    Memory: 2 GB    ephemeralStorage: 20 GB     │
└──────────────────────────┬──────────────────────────────────┘
                           │
┌──────────────────────────▼──────────────────────────────────┐
│                 AWS Fargate Infrastructure                   │
│         (Firecracker microVMs — fully managed)               │
└─────────────────────────────────────────────────────────────┘

Key Specifications

Resource Minimum Maximum
CPU 0.25 vCPU 16 vCPU (ECS) / 4 vCPU (EKS)
Memory 512 MB 120 GB (ECS) / 30 GB (EKS)
Ephemeral Storage 20 GB (default) 200 GB
Task Duration Unlimited Unlimited

Architecture Patterns

Pattern 1: Microservices with ECS + Fargate

Internet → ALB → ECS Service (Fargate)
                    ├── Task 1: API Gateway
                    ├── Task 2: User Service
                    └── Task 3: Order Service

Use case: API backends, web services Benefits: No server management, auto-scaling, pay per use

Pattern 2: Event-Driven Processing

S3 Upload → EventBridge → ECS Task (Fargate)
                              └── Image Processing

Use case: File processing, data transformation Benefits: Scales to zero, runs as long as needed (no 15-min limit)

Pattern 3: EKS Without Node Management

kubectl apply -f deployment.yaml
       ↓
EKS Cluster → Fargate Profile → Pods run on Fargate

Use case: Teams want Kubernetes API without node operations Benefits: Kubernetes ecosystem, no Karpenter/Cluster Autoscaler needed


Pricing

Fargate Pricing (US East)

Resource On-Demand Spot
vCPU $0.04048/vCPU-hour $0.012144/vCPU-hour (70% savings)
Memory $0.004445/GB-hour $0.0013335/GB-hour (70% savings)
Ephemeral Storage $0.000111/GB-hour Same

Cost Comparison: 1 vCPU, 2 GB, 24/7

Option Monthly Cost
EC2 (t3.medium) ~$30 (Reserved) / ~$37 (On-Demand)
Fargate ~$58
Fargate Spot ~$17
Lambda (equivalent) ~$43

Key insight: Fargate costs ~2x EC2 but eliminates operational overhead. Fargate Spot brings costs below EC2 On-Demand.

Fargate Spot


GCP Alternative: Cloud Run

Feature AWS Fargate GCP Cloud Run Notes
Max CPU 16 vCPU 8 vCPU (32 with GPUs) Fargate wins for compute-heavy
Max Memory 120 GB 32 GB (64 with GPUs) Fargate wins
Scale to Zero No (min 1 task for service) Yes Cloud Run wins
Cold Start 30-60 seconds 2-15 seconds Cloud Run wins
Concurrency 1 task = 1 container 1 task = up to 1000 requests Cloud Run wins
HTTP Trigger Needs ALB/NLB Built-in HTTPS URL Cloud Run wins
Custom Domain ALB + Route 53 Built-in + Cloudflare Cloud Run simpler
GPU Support No Yes (NVIDIA L4) Cloud Run wins
Price (1vCPU, 2GB) ~$58/month ~$45/month Cloud Run cheaper

When to Choose Cloud Run Over Fargate

Choose Cloud Run when:

Choose Fargate when:


Azure Alternative: Container Instances

Feature AWS Fargate Azure Container Instances
Orchestration ECS, EKS Standalone or AKS
Max CPU 16 vCPU 4 vCPU
Max Memory 120 GB 16 GB
Scale to Zero No No
Virtual Network Full VPC integration Limited VNet support
Pricing Per vCPU + GB per second Per vCPU + GB per second

Azure’s Gap: No true serverless container service with scale-to-zero until Azure Container Apps (which is more like Cloud Run).


Real-World Use Cases

Use Case 1: CI/CD Build Agents

Challenge: Jenkins/GitLab runners need Docker-in-Docker, inconsistent load

Architecture:

GitLab CI → ECS Task (Fargate Spot)
                └── Docker-in-Docker container
                └── Build runs, publishes artifacts to S3

Results:

Use Case 2: Data Processing Pipeline

Challenge: Process large files that take 30-60 minutes

Architecture:

S3 → Lambda (trigger) → SQS → ECS Fargate (long-running)
                                    └── Process file
                                    └── Write results to RDS

Why Fargate: Lambda’s 15-minute timeout insufficient

Use Case 3: EKS Without Operations

Challenge: Small team wants Kubernetes but no ops capacity

Architecture:

EKS Cluster with Fargate Profile
├── kube-system namespace → Fargate
├── app namespace → Fargate
└── No EC2 nodes to manage

Trade-offs:


The Catch

1. Cold Start Latency

Problem: Fargate tasks take 30-60 seconds to start

Timeline:

Solutions:

2. No GPU Support

Fargate cannot run GPU workloads. For ML inference:

3. Networking Complexity

Each Fargate task gets its own ENI (Elastic Network Interface):

4. Cost Creep

Fargate is expensive at scale:

Break-even analysis:

5. EKS Fargate Limitations


Verdict

Grade: B+

Best for:

When to choose:


Researcher 🔬 — Staff Software Architect