Ref: https://learn.cantrill.io/courses/1820301/lectures/41301614
Amazon ECS - EC2 Mode
Diagram: https://github.com/acantril/aws-sa-associate-saac03/blob/main/1000-CONTAINERS_and_ECS/00_LEARNINGAIDS/ECS-ClusterMode-1.png
- đź”§Â EC2 instances used as container hosts
- Containers deployed to instances (container hosts) via tasks & services
- ECS cluster created by specifying the number of EC2 instances with an ASG
- ASG = AutoScaling Group (controls horizontal scaling for EC2 instances)
- âť—Â Instances visible in EC2 (you can connect to them, stop them, etc)
- Great middle ground: ECS manages container overhead, customer manages container hosts
- 👍 EC2 pricing benefits can be applied → retains some flexibility
- EC2 Reserved Instances (RIs) can be used as container hosts
- EC2 Spot Instances can be used too
- 👎 Management overhead for container hosts (capacity & availability in the cluster)
- ECS provisions the EC2 containers hosts, but customer expected to manage them
- NOT serverless
- ‼️ Once provisioned, you pay for the instances regardless of what containers consume!!
- Container host management can be done through ECS tooling
Amazon ECS - Fargate Mode
Diagram: https://github.com/acantril/aws-sa-associate-saac03/blob/main/1000-CONTAINERS_and_ECS/00_LEARNINGAIDS/ECS-ClusterMode-2.png
- AWS Fargate = Serverless Compute Engine → AWS service that offers a shared infrastructure platform to users
- ECS tasks & services can be allocated inside the AWS Fargate platform
- âť—Â Even if using the same shared pool of HW resources, Fargate users are isolated
- no visibility of other customers
- 💡 similar to how EC2 users are isolated from each other when using shared hosts
- đź”§Â With ECS-Fargate mode, container hosts are managed by AWS (NOT by customers)
- “Serverless” → no overhead for managing container hosts
- No need to manage provisioning, capacity & availability in the cluster
- 👍 Customers only pay based on resources consumed by running tasks
- no visibility of host costs
- Architecture
- Tasks run in AWS Fargate infrastructure
- Tasks injected (from a NWing perspective) into customer's VPC
- A task is provided with an ENI inside the VPC → task gets an IP address in the VPC
- Tasks function like any other VPC resource (even if they run in Fargate infrastructure)
- Tasks from the same cluster can be deployed to different VPCs (only via Fargate)
- Fargate offers a lot of customizability
- You can deploy tasks exactly how you want inside a VPC
ECS Cluster Modes - Summary Table
ECS Cluster Mode |
Container host location |
Container host management |
Billing |
EC2 |
EC2 instances |
Customer |
Pay for whole instances (regardless of container usage) |
Fargate |
AWS Fargate shared infrastructure |
AWS (Fargate service) |
Pay based on resources consumed by running tasks |
Deciding Between EC2, ECS-EC2 and ECS-Fargate
- For apps that require VM exclusive features → Consider plain EC2