Chapter 09 of 12
AMAZON ECS
EC2 or Fargate, and tasks per instance
EC2 or Fargate
| EC2 launch type | Fargate | |
|---|---|---|
| Who runs the machine | You, through an Auto Scaling group | AWS |
| You pay for | EC2 instances, whether full or not | Each task's CPU and memory, per second |
| Control | Instance type, AMI, daemons, GPUs, Savings Plans and Reserved Instances | Less to choose, less to patch |
| Good fit | Steady workloads, many tasks per machine, cost at scale | Spiky or small workloads, teams that want no servers |
Today we build on EC2, because it shows every layer, including the one Fargate hides.
One number to know: tasks per instance
Tasks in awsvpc network mode each get their own network interface (ENI), so an instance can hold only as many tasks as it has spare network interfaces:
tasks per instance = maximum ENIs of the instance type - 1| Instance type | Maximum ENIs | Tasks per instance |
|---|---|---|
| t3.micro | 2 | 1 |
| t3.small | 3 | 2 |
| m6i.xlarge | 4 | 3 |
ENI trunking raises this limit on supported larger instance types. CPU and memory are the other limits.

