CodePark/ questions / Compute: EC2, ECS, Fargate & EKS
START PRACTICINGPRACTICE
Backend question · Cloud & AWS › Compute: EC2, ECS, Fargate & EKS

Explain the main ECS concepts: cluster, task definition, task and service.

ECS (Elastic Container Service) runs containers on AWS. It has four main ideas.

A cluster is a logical group of compute capacity where tasks run. The capacity is either EC2 instances you register, or Fargate (AWS runs the servers for you).

A task definition is a versioned blueprint. Think of it as a richer Docker Compose file. It lists:

  • the containers and their images
  • CPU and memory
  • ports
  • environment variables and secrets
  • log settings
  • the task role and the execution role

A task is one running copy of a task definition. It is one or more containers that are scheduled together.

A service keeps a desired number of tasks running. It:

  • replaces tasks that stop or fail health checks
  • registers tasks with a load balancer target group
  • does rolling deployments when you update the task definition
  • can scale the task count with Application Auto Scaling

One-off jobs, like a database migration, run as standalone tasks without a service.

  • A cluster is where tasks run, on EC2 or Fargate capacity.
  • A task definition is a versioned blueprint of containers, resources and roles.
  • A task is one running copy of a task definition.
  • A service keeps N tasks running, works with load balancers, and handles deploys and scaling.
  • Standalone tasks suit one-off jobs, like a migration.