Skip to content

Fargate

AWS Fargate is a serverless compute engine for containers that works with ECS and EKS.

It allows you to run containers without managing the underlying servers or clusters, fundamentally changing how teams deploy and scale containerized applications on AWS.


AWS Fargate is a serverless, pay-as-you-go compute engine that lets you focus on building applications without managing servers. It is compatible with both Amazon ECS and Amazon EKS, making it a versatile choice for container deployment.

Traditional container deployment requires you to provision, configure, and maintain EC2 instances as worker nodes. With Fargate, AWS handles all of this infrastructure management automatically.

AspectTraditional EC2 LaunchAWS Fargate
Server ManagementYou provision and manage EC2 instancesNo servers to manage
Capacity PlanningYou estimate and plan capacityAWS handles automatically
PatchingYou maintain OS and security updatesAWS manages patching
ScalingYou configure Auto Scaling groupsAutomatic infrastructure scaling
BillingPay for running EC2 instancesPay per vCPU and memory per task
BenefitDescription
Serverless SimplicityNo need to provision, configure, or scale virtual machines
Security by DesignEach task runs in its own isolated compute environment
Right-Sized ComputePay only for the resources your containers actually use
Automatic ScalingFargate scales compute resources based on workload demands
Deep AWS IntegrationNative integration with IAM, CloudWatch, VPC, and other AWS services

Under the hood, Fargate orchestrates isolated Firecracker microVMs for each task or pod. Firecracker is a lightweight virtualization technology (also used by AWS Lambda) that spins up secure, fast-booting VMs.

1. Define Task/Pod → 2. Specify Resources → 3. Deploy → 4. Fargate Provisions → 5. Container Runs
StepDescription
DefineCreate a task definition (ECS) or pod spec (EKS) specifying container images, CPU/memory, networking, and IAM roles
Resource SpecificationSet CPU and memory requirements for your container
DeploymentRun the task or deploy the pod through ECS or EKS
ProvisioningFargate pulls the container image and launches it inside a Firecracker microVM
ExecutionContainer runs with logs sent to CloudWatch and metrics to CloudWatch

When you deploy a Pod to EKS with Fargate:

  1. You define a Fargate profile that specifies which Pods should run on Fargate (using namespace and label selectors)
  2. The Fargate profile installs an admission webhook that intercepts new Pods matching your profile
  3. The webhook mutates these Pods to be scheduled by the Fargate scheduler instead of the default Kubernetes scheduler
  4. The Fargate scheduler evaluates the Pod’s CPU and memory requests and calls AWS APIs to launch the appropriate serverless “node”
  5. The kubelet joins the cluster and binds your Pod to the new Fargate node

Fargate profiles support label- and namespace-based selection, allowing you to target only specific workloads for serverless deployment. This enables hybrid clusters where some Pods run on EC2 nodes and others run on Fargate.


AWS Fargate integrates with both container orchestration services, each offering different benefits.

FeatureECS with FargateEKS with Fargate
OrchestrationAWS-native, simpler setupKubernetes-standard, portable
Learning CurveLowerHigher (Kubernetes expertise needed)
Control PlaneFully managed by AWSFully managed EKS control plane
Pod NetworkingEach task gets its own ENIEach pod gets its own ENI
Windows ContainersSupportedNot currently supported
Arm64 (Graviton)SupportedNot currently supported
Best ForTeams new to containers, AWS-centricTeams with Kubernetes experience, multi-cloud strategies
  • Choose ECS + Fargate if you want the simplest, most integrated experience and don’t need Kubernetes-specific features
  • Choose EKS + Fargate if you have existing Kubernetes expertise, need portability across clouds, or require Kubernetes ecosystem tools

4. Step-by-Step: Deploying a Container with Fargate

Section titled “4. Step-by-Step: Deploying a Container with Fargate”
  • An AWS account
  • AWS CLI configured (optional)
  • Docker installed locally (for building images)
  • Basic understanding of containers

Step 1: Push a Container Image to Amazon ECR

Section titled “Step 1: Push a Container Image to Amazon ECR”
Terminal window
# Authenticate Docker to ECR
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <account-id>.dkr.ecr.us-east-1.amazonaws.com
# Create ECR repository
aws ecr create-repository --repository-name my-fargate-app --region us-east-1
# Tag your local image
docker tag my-app:latest <account-id>.dkr.ecr.us-east-1.amazonaws.com/my-fargate-app:latest
# Push to ECR
docker push <account-id>.dkr.ecr.us-east-1.amazonaws.com/my-fargate-app:latest

A task definition is a blueprint that describes your application:

{
"family": "my-fargate-task",
"taskRoleArn": "arn:aws:iam::account-id:role/ecsTaskRole",
"executionRoleArn": "arn:aws:iam::account-id:role/ecsExecutionRole",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "256",
"memory": "512",
"containerDefinitions": [
{
"name": "web-app",
"image": "account-id.dkr.ecr.us-east-1.amazonaws.com/my-fargate-app:latest",
"portMappings": [{"containerPort": 80, "protocol": "tcp"}],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/my-fargate-app",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
}
}
]
}

Key parameters explained:

  • requiresCompatibilities: ["FARGATE"] - Specifies serverless launch type
  • networkMode: "awsvpc" - Each task gets its own ENI
  • cpu and memory - Resources allocated to the task
  1. Navigate to Amazon ECS in the AWS Console
  2. Click Create cluster
  3. Choose Networking only (Fargate) template
  4. Name your cluster (e.g., my-fargate-cluster)
  5. Click Create
  1. In your cluster, go to the Services tab
  2. Click Create
  3. Select Fargate as the launch type
  4. Choose your task definition and revision
  5. Set Desired tasks (e.g., 1)
  6. Configure VPC, subnets, and security groups
  7. (Optional) Configure load balancing
  8. Click Create
Terminal window
# Create a Fargate-only EKS cluster
eksctl create cluster --name my-fargate-cluster --fargate

What happens automatically:

  • EKS control plane provisioned across multiple Availability Zones
  • Default Fargate profile created
  • CoreDNS is scheduled onto Fargate
  • No EC2 worker nodes are created

Create a Fargate Profile for Your Workload

Section titled “Create a Fargate Profile for Your Workload”
Terminal window
# Create a Fargate profile for the "frontend" namespace
eksctl create fargateprofile --cluster my-fargate-cluster --name frontend-profile --namespace frontend
# Create the namespace
kubectl create namespace frontend
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
namespace: frontend
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
Terminal window
kubectl apply -f deployment.yaml
kubectl get pods -n frontend

Note: Unlike traditional EKS clusters, you will not see any worker nodes in the EC2 console—Fargate is completely serverless.


On AWS Fargate, each ECS Task or Kubernetes Pod is given a dedicated elastic network interface (ENI) attached into your virtual private cloud (VPC). All traffic in and out of the containerized workload goes through this ENI.

Networking FeatureDescription
Dedicated ENIEach task/pod gets its own network interface
Security GroupsVPC Security Groups can be used to secure the ENI
VPC Flow LogsMonitor traffic flows for compliance and troubleshooting
Private SubnetsRun workloads in private subnets for added security
Public IP AssignmentOptional public IP for internet-facing tasks

With Fargate, each workload runs on its own single-use, single-tenant compute instance. Each Amazon ECS Task or Kubernetes pod runs on a newly provisioned instance, isolated by a virtualization boundary.

Key security features:

  • Task-level IAM roles - Each task can have a unique IAM role
  • Compliance programs - PCI DSS, SOC, FIPS 140-2, FedRAMP, and HIPAA eligible
  • HIPAA-eligible - Can process encrypted Protected Health Information (PHI) with executed BAA
PracticeDescription
Use IAM task rolesAssign granular permissions to specific containers
Run in private subnetsKeep workloads isolated from the internet
Enable image scanningUse Amazon Inspector to catch vulnerabilities pre-deployment
Centralize loggingEnable CloudTrail for compliance auditing

Each workload that runs on AWS Fargate is given full access to ephemeral storage to use while the workload is running.

Launch TypeDefault StorageMaximum Storage
ECS with Fargate20 GiB200 GiB
EKS with Fargate20 GiB175 GiB

Important: Once the workload has stopped, any data stored in ephemeral storage is erased.

For stateful workloads requiring data persistence beyond task/pod lifecycle, Fargate supports Amazon Elastic File System (EFS).

EFS integration benefits:

  • Persistent storage across task restarts
  • Shared file access across multiple tasks
  • Automatic scaling of storage capacity

EBS volumes are NOT supported on Fargate. If your application requires EBS block storage, you must use EC2-based ECS or EKS instead.


Fargate integrates with ECS Service Auto Scaling to automatically adjust the number of tasks based on demand.

Scaling PolicyDescription
Target TrackingScale based on metric target (e.g., 70% CPU)
Step ScalingScale based on CloudWatch alarm thresholds
Scheduled ScalingScale based on predictable patterns (e.g., scale up at 9 AM)

For EKS with Fargate, you can use Kubernetes Horizontal Pod Autoscaler (HPA) to scale pod replicas based on CPU/memory utilization or custom metrics.

PracticeDescription
Multiple Availability ZonesDeploy tasks/pods across multiple AZs
Load BalancingUse ALB or NLB to distribute traffic
Desired Task CountRun multiple replicas for redundancy
Health ChecksConfigure health checks for automatic replacement of unhealthy tasks

Fargate provides built-in integration with Amazon CloudWatch for monitoring.

Monitoring ToolPurpose
CloudWatch LogsAutomatically collect logs from containers
CloudWatch MetricsVisualize CPU, memory, and network usage
Container InsightsCollect and analyze logs with operational dashboards
AWS X-RayEnd-to-end tracing for request flows
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/my-fargate-app",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
}

FireLens for Amazon ECS can be used via task definition parameters to route logs to an AWS service or AWS Partner Network destination.

IssueTroubleshooting Step
Container won’t startCheck CloudWatch Logs for container-specific output
Networking issuesVerify subnets and security groups allow required access
Resource constraintsReview CPU/memory settings in task definition
Need live debuggingUse ECS Exec to SSH into running containers

With AWS Fargate, you pay only for the amount of vCPU, memory, and storage resources provisioned by your containerized applications.

ComponentBilling Basis
vCPUPer second from image pull to task/pod termination
MemoryPer second from image pull to task/pod termination
Ephemeral StorageFirst 20 GB included; additional storage billed

Minimum charge: 1 minute per task

Fargate Spot is available for fault-tolerant workloads, offering significant cost savings. You can enable Fargate Spot capacity in your compute environment for workloads that can tolerate interruptions.

StrategyDescription
Right-size resourcesUse AWS Compute Optimizer for recommendations
Use Fargate SpotFor batch jobs and fault-tolerant workloads
Minimize idle timeFargate works best for intermittent workloads
Consider EC2 for always-onAlways-on workloads may be cheaper on EC2
  • Bursty workloads with variable demand
  • Development and testing environments
  • Short-lived batch jobs
  • Microservices with low average utilization
  • Always-on services with consistent high utilization
  • Large-scale sustained workloads
  • GPU-accelerated workloads (not supported on Fargate)

10. Limitations and When NOT to Use Fargate

Section titled “10. Limitations and When NOT to Use Fargate”
LimitationImpactWorkaround
No EBS volumesCannot use block storageUse EFS for persistent storage
No DaemonSets (EKS)DaemonSets cannot schedule on FargateRun agents as sidecar containers
No GPU supportCannot run GPU-accelerated workloadsUse EC2-based ECS/EKS
No privileged containersCannot run Docker-in-Docker or similarUse rootless build tools like Kaniko
No host accessCannot SSH into underlying nodesUse ECS Exec for debugging
Cold start latencyContainers take time to spin upNot ideal for latency-sensitive services
ScenarioBetter Alternative
GPU workloadsEC2-based ECS/EKS
Always-on high-throughput servicesEC2 launch type for cost efficiency
Need fine-grained OS controlSelf-managed EC2 nodes
DaemonSet requirements (EKS)EC2-based node groups
Latency-sensitive applicationsEC2 with warm pools
EBS-dependent applicationsEC2 launch type
Use CaseWhy
MicroservicesIndependent scaling and isolation
Web applications and APIsAutomatic scaling with traffic
Batch processingShort-lived, interruptible jobs
CI/CD pipelinesEphemeral build agents
Event-driven workloadsScale to zero between events
Teams without infra expertiseNo server management required

PracticeDescription
Specify CPU and memory appropriatelyTest locally to understand requirements
Use multi-architecture imagesSupport both x86 and Arm64
Enable zstd compressionImproves startup times
Set log configurationAlways configure CloudWatch Logs
PracticeDescription
Use least privilege IAM rolesGrant only necessary permissions
Run in private subnetsDefault for production workloads
Enable VPC Flow LogsMonitor network traffic
Scan container imagesUse Amazon Inspector before deployment
Rotate secretsUse Secrets Manager for sensitive data
PracticeDescription
Right-size tasksUse AWS Compute Optimizer for recommendations
Use Fargate Spot for batchSignificant savings for fault-tolerant jobs
Monitor with Cost ExplorerTrack and optimize spend
Set budgets and alertsAvoid unexpected charges
PracticeDescription
Use multiple Availability ZonesDeploy across AZs for high availability
Configure health checksEnable automatic replacement of unhealthy tasks
Implement structured loggingUse consistent log formats
Set up CloudWatch alarmsAlert on critical metrics (CPU, memory, errors)
Use ECS Exec for debuggingLive debugging without SSH access

This glossary includes key terms directly related to AWS Fargate.


awsvpc networking mode Networking mode where each Fargate task receives its own Elastic Network Interface (ENI) with a private IP address. Required for Fargate tasks.


CloudWatch Container Insights Monitoring feature that collects and aggregates metrics and logs from Fargate containers, providing operational dashboards for troubleshooting.

Cold Start The latency experienced when a Fargate task or pod first starts up as AWS provisions the underlying Firecracker microVM and pulls container images.

Compute Environment (AWS Batch) A logical grouping of Fargate compute resources used for batch processing jobs. Configured with maximum vCPUs, networking, and optional Fargate Spot.


ECS Exec Feature allowing live debugging of running Fargate containers by executing commands directly inside the container without requiring SSH access.

EFS (Elastic File System) AWS shared file storage service. Fargate tasks can mount EFS volumes for persistent storage that survives task restarts.

ENI (Elastic Network Interface) Virtual network interface attached to each Fargate task or pod. Provides VPC connectivity and can be secured with security groups.

Ephemeral Storage Temporary storage (20 GiB default, up to 200 GiB for ECS or 175 GiB for EKS) provided to each Fargate task. Data is erased when the task stops.


Fargate Launch Type Launch type for Amazon ECS that runs containers on AWS Fargate serverless compute instead of EC2 instances.

Fargate Profile EKS configuration that defines which pods run on Fargate. Uses namespace and label selectors to target specific workloads for serverless execution.

Fargate Scheduler Custom Kubernetes scheduler used when running EKS pods on Fargate. Intercepts pods matched by Fargate profiles and provisions serverless infrastructure.

Fargate Spot Fargate capacity using EC2 Spot Instances at discounted rates. Suitable for fault-tolerant, stateless, or batch workloads that can tolerate interruptions.

Firecracker Lightweight virtualization technology (also used by AWS Lambda) that powers Fargate, providing secure, fast-booting microVMs for each task or pod.


Isolation Boundary Security feature where each Fargate task or pod runs in its own dedicated kernel and compute environment, preventing interference between workloads.


Platform Version Specific runtime environment version for Fargate that determines available features and operating system versions. For Windows containers, specific platform versions are required.


Sidecar Container Secondary container running alongside the main application container within the same Fargate task. Used for logging, monitoring, security agents, or other auxiliary functions.


Task Definition (ECS) JSON-formatted blueprint describing one or more containers for an ECS task. For Fargate, specifies CPU, memory, networking mode, IAM roles, and container images.


zstd Compression Alternative container image compression format (vs. default gzip) that decompresses more quickly, resulting in faster Fargate task startup times.


AWS Fargate fundamentally changes how teams deploy containers on AWS by eliminating server management entirely. With its serverless model, per-second billing, and automatic scaling, Fargate enables teams to focus on building applications rather than managing infrastructure.

Key takeaways:

  • Fargate is serverless compute for containers - No EC2 instances to provision, patch, or scale
  • Works with both ECS and EKS - Choose your orchestration tool
  • Isolation by design - Each task/pod runs in its own dedicated compute environment
  • Pay only for what you use - Per-second billing for vCPU and memory
  • Ideal for variable workloads - Bursty traffic, microservices, batch processing, and dev/test environments
  • Not for everything - GPU workloads, DaemonSets, and always-on high-throughput services may be better on EC2

Getting started recommendations:

  • Start with ECS + Fargate for the simplest path to serverless containers
  • Use the AWS Copilot CLI for building and deploying production-ready applications on Fargate
  • Leverage the AWS Fargate workshops for hands-on learning