Lesson 3 of 6 Amazon ECS, EKS and Fargate

Choosing EC2 or Fargate Capacity for Containers

This lesson explains the capacity options for containers, EC2 instances you manage and serverless Fargate, including Fargate Spot for interruptible tasks.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish the EC2 launch type from Fargate.
  • Describe Fargate characteristics.
  • Choose a container platform.

The options

Containers can run on capacity that ranges from fully self-managed to fully managed. With the EC2 launch type, you run the container instances: you choose instance types, including GPU instances, patch and scale them, and can buy them with Reserved Instances, Savings Plans or Spot. It gives the most control and the highest utilisation when many tasks share instances.

With Fargate, there are no instances to manage; you pay for the vCPU and memory each task requests, which gives the least operational overhead. Fargate Spot runs interruptible tasks on spare capacity at a large discount, with two minutes' notice before a task is stopped. The following table summarises the options.

OptionYou manageBest for
EC2 launch typeContainer instances, types, GPUs; RIs or SpotControl, GPUs, specific instance types, highest utilisation
FargateNothing: pay per task vCPU and memoryLeast operational overhead
Fargate SpotNothing; tasks can be interrupted with two minutes' noticeInterruptible tasks at up to 70% discount
Sort into groups

EC2, Fargate or Fargate Spot?

Exam skills 4.2.3 · 2.1.4

Choose the container capacity option for each workload.

Log in to try this activity Interactive activities are free with an account.

Fargate characteristics

AWS Fargate runs containers without servers to manage. Each task or pod runs in its own isolated environment with its own network interface, in awsvpc networking mode, which gives strong isolation between workloads. There are no instances to patch, scale or right-size; the customer chooses the CPU and memory for each task, and Compute Savings Plans apply.

Fargate has limitations that rule it out for some workloads: it offers no GPUs, does not allow privileged containers, and gives no access to the underlying host. Workloads that need any of these run on EC2 capacity instead.

Select all that apply

What rules Fargate out

Exam skills 2.1.4 · 4.2.3

Identify the requirements that need EC2 capacity instead of Fargate.

Log in to try this activity Interactive activities are free with an account.
Worked example

Choosing a container platform

The appropriate container platform depends on the team's existing tooling and operational requirements. The following table identifies the choice suited to several situations.

SituationChoice
A small team wants to run containers with the least operational effortECS on Fargate
The company already runs Kubernetes on premises and wants the same toolingEKS (with Fargate or managed node groups)
Steady, large container fleet where cost per vCPU matters mostECS or EKS on EC2 with Savings Plans or Spot
Containers need GPUsECS or EKS on EC2 GPU instances (Fargate does not offer GPUs)

Fargate removes server management entirely: no instances to patch or scale. EC2 launch types give more control and can be cheaper at scale, at the cost of managing the cluster's instances.

Check yourself

What does Fargate remove from the team's work?

Show answer

Managing servers: there are no instances to provision, patch or scale, because each task runs on capacity that AWS manages.

Exam Tips

Remember for the exam

  • For containers with the least operational overhead, use ECS on Fargate.
  • When containers need GPUs or particular instance types, use the EC2 launch type.
  • For interruptible container tasks at the lowest cost, use Fargate Spot.
  • To deploy a web application from code with managed infrastructure, use Elastic Beanstalk.