AWS Fargate のアイコン

AWS Fargate Popular2017年〜

A serverless compute engine for running containers without managing servers

What It Does

AWS Fargate is a serverless compute engine for containers. It lets you run Docker containers without any server management - no instance selection, provisioning, scaling, or patching. It works with both ECS and EKS. Just specify the CPU and memory your container needs, and Fargate automatically allocates the right infrastructure. You pay only for what you use.

Use Cases

It is used for serverless microservices operations, rapid provisioning and teardown of dev/test environments, backends for web applications with variable traffic, periodic batch processing and data transformation jobs, and CI/CD pipeline build tasks - anywhere you want container workloads without server management overhead.

Everyday Analogy

Think of it like a ride-hailing service. Instead of owning and maintaining your own car (server), you just tell the service where you want to go (container to run) and how many passengers (CPU/memory needed), and the right vehicle is automatically dispatched. You only pay while riding, with no maintenance or fuel costs to worry about.

What Is Fargate?

AWS Fargate is a serverless compute engine for containers, announced in 2017. Previously, running containers required provisioning EC2 instances, installing Docker runtimes, and handling OS patching and capacity management. Fargate delegates all infrastructure management to AWS, letting you focus solely on defining and running containers. It works as a launch type for both ECS and EKS, enabling migration of existing container workloads with minimal changes.

Key Features

Fargate's biggest feature is the complete elimination of infrastructure management. No EC2 instance selection, cluster capacity planning, or OS security patching is needed. Each task runs in an isolated execution environment, sharing no kernel or resources with other tasks, providing strong security. Combined with auto scaling, task counts adjust automatically based on traffic, preventing cost waste from over-provisioning.

Comparison with EC2 Launch Type

Fargate and the EC2 launch type each have their strengths. Fargate requires no server management and has low operational overhead, but costs more per vCPU than EC2. The EC2 launch type requires instance management but can significantly reduce costs with Reserved Instances or Spot Instances. GPU workloads or special kernel configurations also require the EC2 launch type. Fargate is suited for small-scale workloads where you want to minimize operations, while EC2 is suited for large-scale workloads where cost optimization is the priority. For practical tips on comparing with the EC2 launch type, books on Amazon are also helpful.

Pricing

Fargate pricing is based on the vCPU and memory allocated to tasks and the duration of use. Billing is per second with a 1-minute minimum. You can specify from 0.25 to 16 vCPU and 0.5 GB to 120 GB of memory. Fargate Spot uses AWS spare capacity for up to 70% discount off regular pricing. While there is a risk of interruption, it is well suited for batch processing and fault-tolerant workloads.

Getting Started

To get started, create an ECS cluster and specify Fargate as the launch type in your task definition. The task definition includes the Docker image URL, vCPU and memory allocation, and network settings. Fargate assigns an ENI (Elastic Network Interface) per task, so you use the awsvpc network mode. Create a service and specify the desired task count, and Fargate automatically provisions infrastructure and launches your containers.

Things to Watch Out For

  • Per-vCPU costs are higher than EC2, so for large always-on workloads, compare costs and consider using the EC2 launch type
  • Fargate task storage is ephemeral - data is lost when the task stops. Store persistent data in EFS or S3
共有するXB!