AWS Fargate
Serverless containers
A container runtime for ECS/EKS with no EC2 to manage: you just declare CPU/RAM for each task.
- Cost$$ Medium
- Difficulty●●●●●
- Costs money when idle?Yes
- Serverless
- In examsSAA · DVA · SOA
Think of it asLike shipping goods through a courier instead of buying your own truck.
Where does Fargate fit?
Calls Fargate
A real example, step by step
- You have a video-processing worker that takes about 40 minutes per run — too long for Lambda.
- You package the worker as a container and declare that the task needs 2 vCPUs and 4 GB of memory.
- When a new video arrives, ECS runs a task on Fargate; you don't pick machines, patch an OS or look after a cluster.
- When the task finishes it stops, and you pay for exactly those 40 minutes of 2 vCPUs and 4 GB.
- Videos that aren't urgent run on Fargate Spot, which is much cheaper, accepting the occasional interruption and retry.
When to use it
✓ Use it when
You want to run containers without patching or scaling servers.
✗ Avoid it when
You need specific GPUs or cost optimization for very large, steady load → ECS/EKS on EC2.
Common uses
- Run containers without managing servers
- Short or scheduled containerized tasks
- Variable workloads, small operations team
Fargate, Lambda or EC2?
| Unit of work | A container | A function | A virtual server |
|---|---|---|---|
| Run time | No limit | Up to 15 minutes | No limit |
| Server management | None | None | Yes |
| Billing | vCPU and memory per second while running | Requests and run time | Time the instance is on |
| Best for | Web services, long jobs | Events, short tasks | Software that needs full control of the machine |
What does it cost?
- Pricing model: Per vCPU-hour (~$0.04048) and GB-hour of memory (~$0.004445), billed per second (1-minute minimum). Fargate Spot is up to ~70% cheaper.
- Free tier: None.
More expensive than EC2 for large, steady load; pulling images through a NAT Gateway; ephemeral storage above 20 GB costs extra.
“Containers” + “no servers to manage” → Fargate. Tasks longer than 15 minutes that should still be serverless → Fargate instead of Lambda. GPUs, or cost-optimizing very large steady workloads → EC2.
Try real exam questions
1A company is running a multi-tier web application on premises. The web application is containerized and runs on a number of Linux hosts connected to a PostgreSQL database that contains user records. The operational overhead of maintaining the infrastructure and capacity planning is limiting the company's growth. A solutions architect must improve the application's infrastructure. Which combination of actions should the solutions architect take to accomplish this? (Choose two.)
- AMigrate the PostgreSQL database to Amazon Aurora.
- BMigrate the web application to be hosted on Amazon EC2 instances.
- CSet up an Amazon CloudFront distribution for the web application content.
- DSet up Amazon ElastiCache between the web application and the PostgreSQL database.
- EMigrate the web application to be hosted on AWS Fargate with Amazon Elastic Container Service (Amazon ECS).
Show answer
Correct answer: A, E
Move the database to Aurora (a managed service) and run the containers on Fargate with ECS: no servers to operate and no capacity planning. Moving to EC2 still means managing machines yourself.
2A company's near-real-time streaming application is running on AWS. As the data is ingested, a job runs on the data and takes 30 minutes to complete. The workload frequently experiences high latency due to large amounts of incoming data. A solutions architect needs to design a scalable and serverless solution to enhance performance. Which combination of steps should the solutions architect take? (Choose two.)
- AUse Amazon Kinesis Data Firehose to ingest the data.
- BUse AWS Lambda with AWS Step Functions to process the data.
- CUse AWS Database Migration Service (AWS DMS) to ingest the data.
- DUse Amazon EC2 instances in an Auto Scaling group to process the data.
- EUse AWS Fargate with Amazon Elastic Container Service (Amazon ECS) to process the data.
Show answer
Correct answer: A, E
Kinesis Data Firehose ingests streaming data with no servers to manage. A 30-minute job exceeds Lambda's 15-minute limit, so it runs on Fargate with ECS. EC2 Auto Scaling isn't serverless.
Frequently asked questions
What is the difference between Fargate and ECS?
ECS (or EKS) is the orchestrator for your containers. Fargate is where the containers run, without you managing servers. In other words, you use ECS to describe what to run and choose Fargate so AWS takes care of the machines.
When should I not use Fargate?
When you need GPUs or a specialized machine configuration, need deep access to the operating system, or run very large, steady workloads that would be cheaper on EC2 (especially with Savings Plans or Spot).
How is Fargate priced?
By the vCPU and memory each task or pod requests, billed per second while it runs. Fargate Spot is much cheaper, but tasks can be stopped when AWS needs the capacity back.
What do AWS exams ask about Fargate?
Scenarios where you want to run containers without managing servers, comparisons with Lambda (use Fargate for tasks longer than 15 minutes) and with the EC2 launch type in terms of cost and control.