AWS · Containers

Amazon ECS

AWS's own container orchestrator: run and scale Docker containers as tasks and services on EC2 or serverless Fargate capacity.

On the SAA-C03 exam listAutomationLoad balancing

What it is and what problem it solves

Amazon Elastic Container Service (ECS) runs containers. A task definition describes one or more containers (image, CPU, memory, ports, environment, IAM role). A task is a running copy; a service keeps the desired number of tasks running, replaces failed ones, registers them with a load balancer and rolls out new versions. Tasks run on a cluster backed by capacity you choose: Fargate (no servers to manage), EC2 instances you manage, ECS Managed Instances, or on-premises servers with ECS Anywhere.

ECS is simpler than Kubernetes and deeply integrated with IAM, load balancers, CloudWatch and other AWS services.

OrchestratorECS (AWS-native) or EKS (Kubernetes)EC2 launch type: you run the serversFargate: no servers to manageEC2 instancetasktaskEC2 instancetasktasktaskown CPU, RAMtaskown CPU, RAMtaskown CPU, RAM
Containers on AWS: pick an orchestrator (ECS or EKS), then run tasks on EC2 you manage or on Fargate

When to use it

  • Containerised web services, APIs, workers and scheduled jobs on AWS.
  • Teams that want container orchestration without running Kubernetes.
  • Each task needs its own IAM role, security groups and log stream.

When to avoid it

  • You need Kubernetes APIs, tooling or portability across clouds: EKS.
  • Simple event-driven functions: Lambda.
  • A single static website: S3 and CloudFront.

Scaling model and bottlenecks

Service auto scaling adjusts the task count by target tracking (CPU, memory, requests per target) or steps. On EC2 capacity, capacity providers scale the instances to fit the tasks; on Fargate there are no instances to scale.

Limits and quotas

ItemValueContextSource
Services per cluster 5,000
Fixed limit
Source
checked
Tasks per service (desired count) 5,000
Fixed limit
Source
checked
Clusters per Region 10,000
Can be raised with a quota request
Source
checked
Containers per task definition 10
Fixed limit
Source
checked

Quotas and limits change. Check the linked source before designing around a number.

Cost model

What you pay for

There is no additional charge for ECS orchestration. You pay for the capacity: Fargate vCPU and memory, EC2 instances, a per-instance management fee for ECS Managed Instances, or a per-instance-hour fee for ECS Anywhere on premises.

Where it is cost-efficient

Packing many tasks onto right-sized EC2 instances with capacity providers, or Fargate for spiky services where you would otherwise over-provision instances.

Where costs grow

Over-sized task definitions, idle services kept at high counts, and NAT gateway traffic from tasks in private subnets pulling images.

Cost controls and common surprises

Right-size task CPU and memory, scale services in, use Fargate Spot or EC2 Spot for interruptible work, and use VPC endpoints for ECR and S3 to avoid NAT charges.

Prices differ by Region and change over time; see the pricing page linked under Sources.

Security

Controls the service provides

A task role per task definition for application permissions, a separate execution role for pulling images and writing logs, and awsvpc networking that gives each task its own network interface and security groups.

What you configure

Scan images, run containers as non-root with read-only file systems where possible, give each task least-privilege roles, and inject secrets from Secrets Manager or Parameter Store.

Logging and monitoring

awslogs driver to CloudWatch Logs or FireLens to other destinations; Container Insights metrics; CloudTrail.

Related security services

ECR with Inspector scanning, Secrets Manager, IAM, GuardDuty runtime monitoring.

Shared responsibility

AWS runs the control plane (and the infrastructure on Fargate). You secure images, task definitions and, on EC2, the instances.

Availability, backup and failure behavior

Services spread tasks across Availability Zones and replace failed tasks; with a load balancer, unhealthy tasks are removed from rotation. Deployment circuit breakers roll back failed releases.

Common service combinations

ECR for images, Fargate or EC2 capacity providers, Application Load Balancer, Cloud Map service discovery, Secrets Manager, CloudWatch Container Insights.

Business application examples

  • A web API on Fargate behind an ALB, scaling on requests per task.
  • Background workers on EC2 Spot capacity reading from SQS.

Exam cues and common confusions

  • Containers without managing servers: ECS on Fargate. Need control of instances or GPUs: ECS on EC2.
  • Permissions for the application in a task: the task role (not the instance role).
  • Kubernetes required: EKS.

Related

Courses and lessons

Services, comparisons and patterns

Sources

Independent study material, not affiliated with or endorsed by Amazon Web Services. AWS and service names are trademarks of Amazon.com, Inc. or its affiliates.

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake