ECS

Launch Type

Task

ECS cluster

Capacity Provider

Fargate

EC2

on premise

Network - VPC

Namespace

Monitoring Option

Cloudwatch container inside

service to service communication

With EC2 launch type

Fargate

EC2

Capacity Provider Strategy

For Fargate

Create capacity providers
then add them to capacity provider strategies

Task Definition

Attrs

Each EC2 instance must run
ECS agent to register in ECS cluster

this means ECS agent containers
must run inside EC2 instances

Multiple containers can run inside each EC2 container

AWS is responsible for provisioning and managing containers, depends on your tasks needs

  • CPU
  • Ram
  • Storage

Scale

Auto scaling group

AWS runs tasks for you.
To scale, just add more tasks

It's serverless

AWS takes care of running/stopping containers

You must provision and
maintain EC2 infrastructure
by yourself

IAM Roles

Used by ECS agent only

Makes api calls to ECS service

Send container logs to CloudWatch Logs

Pull docker image from ECR

Reference sensitive data in Secrets Manager or SSM Parameter Store

IAM Roles

EC2 Instance Profile / Task execution role

ECS Task Roles

Defined in task definition

Allow each task to have a specific role

used by container Agent

EC2 launch type o nly

has specific role

Run Tasks

ELB

ALB / NLB

ELB for tasks

Data Volumes

EFS (Fargate)

Mount EFS file systems onto ECS tasks

Both EC2 and Fargate

Fargate + EFS = serverless

Task definition

Infrastructure

Launch Types

Operation System

Linux

Window

Network ( EC2 only )

task size

CPU

Memory

Task role vs execution role

Containers

image, registry

Port mapping

Resource

CPU, GPU, Mem soft/hard limit

Mem soft limit: if the system memory is under contention, Docker attempts to keep the container memory to this soft limit

Mem hard limit: if the container attempts to hard limit, the container stops

Services / tasks

min/max running task

designed task

config auto scaling

rolling updates

metrics:

  • CPU
  • Ram
  • Requests

Types

Target tracking

Step scaling

Schedule

Scale based on cloudwatch metrics

Scale based on cloudwatch alarm

Auto scale

Log / Monitors

Tasks can be triggered by EventBridge

Storage

Monitoring

Logging

Environment Variables

attach volumes

up to 10 conainers per task definition