EC2 is a fine tool that I rarely need. For a container that answers HTTP all day, Fargate costs about the same in Sydney for the same shape, without a server to patch, an image to rebuild or an autoscaling group to babysit. So I start there.
EC2 earns its place when the job needs the machine itself: GPUs, special instance types, local disks, a vendor appliance, or a big steady fleet where a three-year commitment and packing services onto instances save more than the operations cost. For an always-on box that runs agents, I don't use AWS at all (Why I ended up on AWS).
Use it when
- You need what Fargate doesn't have: GPUs, special instance types, local NVMe disks.
- A large, steady fleet on a three-year commitment, where packing many services per instance saves more than the patching costs.
- Software that must run on a full machine you control: a vendor appliance, a licensed agent, a kernel setting.
Don't use it when
- A plain container service: in Sydney, Fargate costs about the same for the same shape, and there are no machines to patch.
- An always-on box for agents and previews: a Hostinger VPS costs a fraction of it.
- Anything spiky or event-driven: Lambda.
Pricing
Sydney, on demand: c7g.large (2 vCPU, 4 GB) $0.0944 an hour, about $68.91 a month; m7g.large (2 vCPU, 8 GB) $0.102 an hour, about $74.46; t4g.small $0.0212 an hour. Fargate on Arm with 2 vCPU and 4 GB is $0.09474 an hour, about the same. Compute Savings Plans take 24% (1 year) to 48% (3 years) off m7g.
Gotchas, with fixes
Gotcha: Burstable t4g instances sustain only 20 to 40% of each vCPU before their credits run out.
Fix: Use them for light, idle-heavy loads; size steady work on c7g or m7g.
Gotcha: Every instance is an operating system to patch, an image to rebuild and an autoscaling group to keep healthy.
Fix: Use Fargate unless you need what only EC2 has, and automate images and patching from day one when you do.
Provisioning
Official Pulumi package · Official Terraform provider
aws.ec2.Instance, LaunchTemplate and autoscaling Group in @pulumi/aws.
Instead, consider
- Fargate services (always on) A container service: same price in Sydney, no servers.
- Hostinger VPS One always-on box for agents, jobs and previews.
- AWS Lambda Spiky traffic and events.
Worked examples
Sources
Last reviewed by Nicolas Dao