Comparing different launch types of EKS/ECS: Fargate vs EC2
- Fargate runs docker containers serverless. Fargate utilizes Docker containers and runs them virtually.
- Fargate allows you to run containers without having to manage servers or clusters.
- No need to scale, provision or configure clusters of virtual machines to run containers.
- No need to choose server types and how they communicate
- Fargate launch type
- Pack application in containers, specify the memory/CPU requirements, define IAM or network polocies and launch app.
- EC2 launch type
- Define server level, more granular control over the infrastructure, allows you to find best server for app based on requirementss
- No cluster management
- Seamless scaling
- Integration with Amazon ECS
- Abstracts infrastructure = secure container deployments - embed maximum security within a container.
- Lower the costs
- Charges for particular time span app workloads are running
- Able to determine the right number of containers to run on any given host
- Roughly 10% cost reduction
- Reduces complexity
- Build the container image in the first step
- Define resources and images needed for app
- Launch containers and fargate manages infrastructure
- AWS runs containers, scales and manages availability
- EC2 launch type - billing is based on underlying EC2 instances
- EC2 launch type - optimize the process by taking advantage of billing models like spot instances / reserved
- EC2 launch type - customer responsibility to make sure that containers are densely packed onto instances to get max cost benefit . You pay per second - minimum of a minute
-
Workload is consistent for CPU or memory - run EC2
-
Large cluster of EC2 instances is harder to maintain - if you cant handle it use Fargate
-
Small workload - Fargate
-
Small test environment - Fargate
-
Conisstent periodic tasks from a queue - Fargate
-
General purpose workload - Fargate
You can assume that Fargate will run on general purpose EC2 instances e.g. t or m. AWS didn't specify what instances are used for Fargate, we can assume it can also run at old type of instances eg. t2 or m4
-
Workload with CPU intensive, memory intensive, need high network performance or need special hardware such as GPU - choose EC2.
CPU | Memory Values |
---|---|
0.25 vCPU | 0.5GB, 1GB, and 2GB |
0.5 vCPU | Min. 1GB and Max. 4GB, in 1GB increments |
1 vCPU | Min. 2GB and Max. 8GB, in 1GB increments |
2 vCPU | Min. 4GB and Max. 16GB, in 1GB increments |
4 vCPU | Min. 8GB and Max. 30GB, in 1GB increments |
References: