Fargate, EC2 and capacity providers
Choose the compute behind ECS
Fargate is a compute option for containers: you choose supported task resources and AWS manages the underlying infrastructure. Self-managed EC2 capacity uses instances you operate, patch and size; ECS places tasks on those instances. ECS Managed Instances is another managed capacity option with EC2 flexibility; it is not identical to Fargate. Check regional and workload support before selecting any option. ECS can run workloads on different capacity types; ECS itself is not a virtual machine.
Capacity providers and interruption
A capacity provider connects task placement to a source of compute. For example, a Fargate strategy can specify FARGATE with base 1 and weight 1, plus FARGATE_SPOT with weight 1. Base assigns the first task to FARGATE; weights guide allocation of the remaining tasks, not an exact split for every small count. Fargate Spot can be interrupted; use it for retryable workers and persist progress externally. Do not treat it as guaranteed capacity or assume automatic fallback to regular Fargate. Self-managed EC2 Auto Scaling group providers are a separate strategy family.
Size a task and scale a service
For a small Linux Fargate task, 256 CPU units and 512 MiB is one supported combination. Not every CPU and memory pair is valid. Choose using measurements of CPU usage, memory pressure and application latency; raising the desired count adds tasks, whereas changing task size requires another definition revision and deployment. Service Auto Scaling adjusts desired count within configured limits based on selected policies. With EC2 capacity, scaling the cluster and scaling the service are separate decisions. Bound both to avoid runaway cost.
Estimate cost before deployment
Use hypothetical hourly rates of $0.04 per vCPU and $0.005 per GB of memory. For two tasks, each 0.5 vCPU and 1 GB, running for 10 billable hours: 2 × 10 × (0.5 × 0.04 + 1 × 0.005) = $0.50 compute subtotal. Real Fargate charges depend on operating system, architecture, region, requested resources and billable duration including image download, with minimums; additional ephemeral storage may be charged. Add load balancer, logs, NAT/endpoints, public IPv4, transfer and retained storage where applicable. These are invented rates, not a quotation. Compare EC2 idle capacity and management effort as well.
Practice: choose for a workload
A small team runs a steady API and a batch worker that can retry. Propose regular Fargate for the API and consider Spot for the retryable worker after reviewing interruption risk; compare EC2 or Managed Instances if hardware, placement or long-term utilization requirements justify them. Explain which expenses remain when the service is scaled to zero. Do not assume deleting tasks removes load balancers, logs or gateways.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Fargate, EC2 and capacity providers — knowledge check
Apply the lesson to offline ECS scenarios.
Which capacity is a sensible candidate for a retryable batch worker?
What does FARGATE base 1 express in the sample strategy?
How can you add more identical task replicas within configured limits?
At the example rates, what is the compute subtotal for two 0.5-vCPU, 1-GB tasks over 10 billable hours?
What remains possible when desired count becomes zero?