Lambda vs Fargate: AWS Cost Comparison
A simple guide to understanding the costs of AWS Lambda and Fargate, and choosing the most cost-effective option for your needs.
🟦 AWS Lambda – Cheaper if you’re doing small things
- You pay per invocation (every time your code runs).
- You also pay for execution time (e.g., 100 ms, 500 ms…).
Example:
If your code runs for 1 second, 100 times a day → you pay almost nothing.
So Lambda is a great fit if:
- You have small functions
- You don’t need an app that runs all the time
- You want to optimize costs
🟧 AWS Fargate – More expensive but built for full applications
- You pay per second your container runs (CPU + RAM).
- Even if nobody is using your app, you pay as long as it’s running (unless you shut it down).
Example:
You run a container 24/7 with 0.5 vCPU and 1 GB of RAM → about $10 to $15/month minimum.
So Fargate is better if:
- Your app runs all the time
- You need a real API or a full website
- You have more business logic than a simple function
Direct Cost Comparison (approximate)
| Service | Typical use | Estimated cost |
|---|---|---|
| Lambda | Short function (e.g., sending an email, resizing an image) | A few cents to $1/month |
| Fargate | Web application (e.g., Node.js + API) running 24/7 | $10–$30/month per container |
The Very Simple Summary:
| You want to save as much as possible | → Lambda (if your app can work as functions) |
|---|---|
| You want a full app that keeps running | → Fargate (more expensive, but more powerful) |
Cost Breakdown
AWS Lambda
- Per-request billing: ~$0.0000002 per request
- Duration billing: ~$0.00001667 per GB-second
- Free: 1 million requests/month
- Free: 400,000 GB-seconds/month
AWS Fargate
- Per-vCPU billing: ~$0.04048/hour
- Per-GB RAM billing: ~$0.00445/hour
- Recommended minimum: 0.5 vCPU + 1 GB RAM
- No free tier
Real-World Cost Examples
Lambda Example
- Email-sending function
- 100 invocations/day
- 1 second of execution
- Monthly cost: ~$0.01
Fargate Example
- Node.js API
- Runs 24/7
- 0.5 vCPU + 1 GB RAM
- Monthly cost: ~$15
Cost Optimization
For Lambda
- Optimize execution time
- Reduce allocated memory
- Use the free tier
- Group functions together
For Fargate
- Right-size your containers
- Use auto scaling
- Stop unused containers
- Choose the right region
Conclusion
The choice between Lambda and Fargate depends on your needs and your budget:
- Lambda: ideal for small functions and minimal costs
- Fargate: better for full applications that run continuously
Additional Resources
About InSkillCoach
Training and technology expert
Coach specializing in advanced technologies and AI, backed by GNeurone Inc.
Certifications:
- AWS Certified Solutions Architect – Professional
- Google Cloud certifications
- Microsoft Certified: DevOps Engineer Expert
- Certified Kubernetes Administrator (CKA)
- CompTIA Security+
Comments
Comments are powered by GitHub Discussions
Sign in with GitHub to join the discussion