
Want to Use Amazon ECS without an ALB and Save Money?
I tried reducing Amazon ECS fixed costs by using API Gateway HTTP API, VPC Link, and AWS Cloud Map instead of an ALB. This post shares the architecture and rough cost comparison.
Hi, I’m mu7889yoon, It is pronounced “yoon”.
This is my first post in English.
Personally, when I want to run something on AWS, my selection process is usually something like this:
- Can I do it with AWS Step Functions?
- AWS Lambda
- Amazon ECS (Fargate)
That is roughly how I think about it.
Then, when I choose ECS, the thing that immediately stands in my way is the ALB.
ALB cost is based on running time and data transfer.
For personal use, honestly, a fixed cost of over 15 USD per month is pretty painful...
Even if I start ECS tasks only when I need them, the ALB keeps running all the time, so the cost-saving benefit becomes pretty weak.
In this post, I’ll show how I tried running ECS by using API Gateway HTTP API kind of like a load balancer.
The architecture looks roughly like this:
API Gateway → VPC Link → Cloud Map (Service Discovery) → ECS (Fargate)
This architecture is based on an AWS Architecture Blog article published in 2020.
What is AWS Cloud Map?
AWS Cloud Map is a service for resource discovery.
ECS tasks may get different IP addresses every time they start, but by using Cloud Map, you can resolve the IP addresses of ECS tasks with a name like
backend.ecs.local.Build & Deploy
I manage everything with AWS CDK.
The code is available here .

I tried running it
Let’s access the API Gateway endpoint.

It worked.
For later verification, I made the response show the IP address.
Next, I increased the number of tasks to two.

The IP addresses are different, so we can see that traffic is being load balanced.
When I checked Cloud Map from the AWS Management Console, the tasks were registered under the service (
backend).
Cost
Here is a rough estimate for the Osaka Region.
Why Osaka instead of Tokyo? No deep reason - I just love Osaka.
| Service | Cost per month |
|---|---|
| Fargate (0.25 vCPU, 0.5 GB) | 11.25 USD |
| Application Load Balancer | 17.75 USD |
| ECR | 1.08 USD |
| Total | 30.08 USD |
By moving from ALB to API Gateway + Cloud Map, it becomes...
| Service | Cost per month |
|---|---|
| Fargate (0.25 vCPU, 0.5 GB) | 11.25 USD |
| ECR | 1.08 USD |
| API Gateway | ≒ 0 USD |
| Cloud Map | ≒ 0 USD |
| Route 53 Private Hosted Zone | 0.50 USD |
| Total | 12.83 USD |
And if I additionally use Graviton (Arm), it gets even cheaper.
| Service | Cost per month |
|---|---|
| Fargate (0.25 vCPU, 0.5 GB, Arm) | 8.99 USD |
| ECR | 1.08 USD |
| API Gateway | ≒ 0 USD |
| Cloud Map | ≒ 0 USD |
| Route 53 Private Hosted Zone | 0.50 USD |
| Total | 10.57 USD |
I’m very happy that I was able to reduce the cost to about one-third of the traditional architecture.
I had already been starting ECS tasks only when needed, but since the ALB keeps running all the time, the fixed cost remained and the savings were not that impressive.
With this architecture, I can remove that fixed cost, so the overall cost becomes much lower.
Because I am a super frugal person who loves saving money, I am also running this with Fargate Spot + starting it only during the time periods when I use it.
Summary
For learning environments or personal-use environments, I think this setup is more than enough.
When you want to use ECS but are worried about the ALB cost, I hope this gives you another option.
Have a cost-effective and happy container life :D
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article