Which is cheaper: running the same app on ECS or EC2? πŸ’Έ

“Running it in a container will reduce costs,” is that thought,

true? Let’s check the numbers directly.

>

🎯 What this article covers

  • Why ECS and EC2 have different pricing models
  • Which is cheaper based on the same performance criteria
  • Why the conclusion changes depending on cluster utilization
  • A realistic comparison considering discount options like Savings Plan and Spot
  • What is the position of the new ECS Managed Instances released in 2025

πŸ“Œ Introduction β€” Is the question “ECS vs EC2” itself flawed?

When using AWS, this question naturally arises:

“Which is cheaper: deploying the same application directly on EC2,

or deploying it with ECS (containers)?”

However, there’s a trap in this question. ECS and Fargate are not competitors. ECS is a container orchestration service, and Fargate is one of the compute options for running ECS tasks.

In other words, the correct comparison targets are as follows:

Comparison Target Description
Pure EC2 Directly deploy apps on VM, manage all infrastructure yourself
ECS on EC2 Run containers on EC2 instances, ECS handles scheduling
ECS on Fargate Serverless, AWS manages all infrastructure

Let’s compare these three based on the same performance criteria.


πŸ” First, understand the pricing structure

πŸ’‘ EC2 (Pure or ECS on EC2)

EC2 is billed per instance. Whether the utilization is 20% or 100%, the cost is incurred for as long as the instance is running.

λΉ„μš© = μΈμŠ€ν„΄μŠ€ μ‹œκ°„λ‹Ή μš”κΈˆ Γ— μ‹€ν–‰ μ‹œκ°„

Example: t3.medium (2 vCPU / 4GB) β†’ approx. $0.0416/hr (us-east-1 On-Demand standard)

πŸ’‘ ECS on Fargate

Fargate is billed for the vCPU and memory usage requested by the task, from the time the container image is pulled until the ECS task terminates.

λΉ„μš© = (vCPU μš”κΈˆ Γ— μ‚¬μš© vCPU Γ— μ‹œκ°„) + (λ©”λͺ¨λ¦¬ μš”κΈˆ Γ— μ‚¬μš© GB Γ— μ‹œκ°„)

Example: Running a 1 vCPU + 2GB task for 730 hours (1 month)

  • vCPU: $0.04048 Γ— 1 Γ— 730 = $29.55
  • Memory: $0.004445 Γ— 2 Γ— 730 = $6.49
  • Total: approx. $36.04/month

Same spec EC2 (t3.small 2vCPU/2GB): $0.0208/hr Γ— 730 = approx. $15.18/month

πŸ“Œ Based on specs alone, EC2 is about 2 times cheaper. But that’s not the whole story.


βš–οΈ Utilization is key

The decisive variable in cost comparison is EC2 instance utilization.

EC2-based ECS pays a fixed cost for the memory and capacity of the chosen instance type. Regardless of how much the workload actually uses, the full instance cost is paid. Fargate, on the other hand, is billed only for the CPU and memory consumed by a single task, so costs can be more closely aligned with actual resource requirements.

Scenario comparison (based on 10 vCPU / 20GB workload)

Utilization ECS on EC2 (On-Demand) ECS on Fargate Cheaper Option
90% or more Approx. $350/month Approx. $520/month βœ… EC2
50~60% Approx. $350/month Approx. $520/month βœ… EC2
30% or less Approx. $350/month (waste occurs) Billed proportional to actual usage βœ… Fargate advantageous
Intermittent execution Maintenance cost remains the same Billed only for execution time βœ… Fargate overwhelmingly advantageous

Up to a certain threshold, Fargate’s precise billing is more cost-effective than EC2-based. However, beyond that threshold, managing your own EC2 fleet becomes more cost-effective than Fargate.


πŸ’» Practical Simulation β€” Based on the same app

Let’s compare directly under the following conditions:

  • One web application, operating 24/7
  • Required specs: 2 vCPU, 4GB memory
  • Region: ap-northeast-2 (Seoul)
  • Basis: 1 month (730 hours)

Direct EC2 operation (t3.medium, On-Demand)

# Check t3.medium On-Demand price in Seoul region
aws pricing get-products 
  --service-code AmazonEC2 
  --filters 'Type=TERM_MATCH,Field=instanceType,Value=t3.medium' 
             'Type=TERM_MATCH,Field=location,Value=Asia Pacific (Seoul)' 
  --query 'PriceList[0]'
  • t3.medium (2vCPU / 4GB): approx. $0.052/hr
  • Monthly cost: $0.052 Γ— 730 = approx. $37.96
  • Reserved Instance (1 year): approx. $22~25/month (approx. 40% savings)

ECS on Fargate (2 vCPU / 4GB, always running)

# Calculate Fargate monthly cost in Seoul region
# vCPU: $0.04656/hr (Seoul standard)
# Memory: $0.00512/GB/hr (Seoul standard)

python3 -c "
vcpu_cost = 0.04656 * 2 * 730
mem_cost  = 0.00512 * 4 * 730
print(f'vCPU λΉ„μš©: ${vcpu_cost:.2f}')
print(f'λ©”λͺ¨λ¦¬ λΉ„μš©: ${mem_cost:.2f}')
print(f'총 Fargate μ›” λΉ„μš©: ${vcpu_cost + mem_cost:.2f}')
"
# vCPU cost: $67.98
# Memory cost: $14.95
# Total Fargate monthly cost: $82.93

###

Summary of Results

Option Monthly Cost Notes
EC2 On-Demand ~$38 Requires direct management
EC2 Reserved (1 year) ~$23 Requires long-term commitment
Fargate On-Demand ~$83 No management required
Fargate Spot ~$25 Potential for interruption
Fargate Savings Plan (1 year) ~$55 Approx. 30% savings

πŸ“Œ For a single, always-on workload, EC2 is 2-3 times cheaper.


πŸ†• New Option in 2025 β€” ECS Managed Instances

Amazon ECS Managed Instances, announced in September 2025, combine the operational convenience of Fargate with the flexibility of EC2. AWS manages the infrastructure while allowing access to various EC2 instance types.

Managed Instances add a management fee of $0.02/hr to EC2 pricing. The fee is the same regardless of the instance type. This means whether you use t3.micro or m5.24xlarge, an additional $0.02/hr will be incurred.

If you find direct EC2 management burdensome but Fargate pricing too high, this could be a good middle ground.


🎭 Fargate Spot β€” The Hidden Card

Workloads that can tolerate interruptions, such as batch jobs, development environments, or stateless services, can achieve up to 70% savings by running on Fargate Spot.

For development/test environments or asynchronous batch processing, Fargate Spot can actually be cheaper than EC2.


⚠️ Hidden Costs β€” Non-compute items

Estimating costs based solely on Fargate compute charges often leads to underestimation by 30-50%. In addition to compute costs, the following are added:

  • ALB (Application Load Balancer): Approx. $16-25/month fixed + traffic costs
  • NAT Gateway: $0.059/hr + $0.059/GB for data processing
  • CloudWatch Logs: $0.76/GB for log ingestion, $0.033/GB/month for storage
  • ECR: $0.10/GB/month for container image storage

For EC2, operational personnel costs must also be considered. Patching, security configuration, and autoscaling setup are invisible costs.


βœ… Summary β€” When to choose what?

Situation Recommendation
24/7 operation, utilization 60% or more EC2 (On-Demand or Reserved)
No infrastructure management resources, quick start ECS Fargate
Intermittent/batch workloads Fargate Spot
EC2 economy + management convenience ECS Managed Instances (New in 2025)
Irregular traffic with frequent Scale Up/Down ECS Fargate

Key Conclusions in Three Lines:

  1. If it’s a simple comparison based on specs, EC2 is 2-3 times cheaper than Fargate.
  2. If utilization is low or traffic is variable, Fargate can be more advantageous.
  3. From a TCO (Total Cost of Ownership) perspective, the true answer comes from calculating including operational personnel costs.

The most accurate way is to directly compare your workload specs using the AWS Pricing Calculator (calculator.aws). As an official tool, it allows for detailed simulations by region and purchase option.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *