The dramatic cost savings that serverless compute can deliver are well known. However, understanding the pricing structure of AWS Lambda and predicting exactly what your first bill will look like is still very difficult. This guide, and the calculator below, will help you calculate the cost of using AWS Lambda along with additional options to calculate the price for add-on services like WebSockets, provisioned concurrency, and lambda edge.
AWS Lambda Cost Calculator
Number of Executions (per month):
Average Request Duration (ms):
Amount of Memory Allocated (mb):512 mb
(min – 128 / max – 3008)
Provisioned Concurrency Amount:
(max – 1000)
Provisioned Concurrency Time (minutes/month):
AWS Free Tier
Includes 1M free requests and 400,000 GB-seconds
of compute time per month.
Average Monthly Spent
AWS Lambda Pricing Calculation 101
AWS Lambda Cost – How It Works
AWS bills for Lambda based on execution time. They calculate the execution time of each function in 100ms increments and always round up. The minimum execution time they will charge you for is 100ms, so any function that runs for less than 100ms will be billed at 100ms. How much they charge per 100ms is based on memory size. Here is a breakdown of how much they charge for each memory size they offer.
|Memory (MB)||Price per 100ms|
Understanding AWS Lambda’s Free Tier
AWS offers a relatively generous free tier for AWS Lambda that be used to get started and for small applications. The free tier has two caps on it. The first limit is 1 million requests per month. No matter what memory size you select for your lambdas, you can never exceed 1 million requests per month and remain in the free tier. The second limit is 400,000 GB-seconds of compute time per month. This means that if you utilize the lowest Lambda memory level of 128MB, you could run roughly 3.2 million seconds of compute time per month. If you utilizerd the highest Lambda memory level of 3,008MB, you could run roughly 135,000 seconds of compute time per month.
AWS Lambda@Edge Pricing – How It Works
Lambd@Edge pricing works slightly different than regular Lambda pricing. First off, there is no free tier. Second, execution is priced in increments of 50ms rather than in in 100ms increments. After that the calcualtion is pretty simple: $0.60 per 1M requests and $0.00005001 for every GB-second. Again, the size of your Lambda and the total execution time are the two variables needed to calculate cost.
AWS Lambda Provisioned Concurrency Pricing – How It Works
Provisioned concurrency basically means that you are paying for capacity upfront in exchange for a discount. If you have consistent Lambda usage it is a great way to cut down on costs. The pricing for provisioned concurrency introduces a 3rd pricing variable; in addition to requests and duration, you are also billed on the total amount of concurrency (in GB-seconds) that you want provisioned. The price breakdown for US East is below.
|Provisioned Concurrency||$0.0000041667 for every GB-second|
|Requests||$0.20 per 1M requests|
|Duration||$0.0000097222 for every GB-second|
AWS Lambda Cost Optimization Tips – Best Practices
1. Utilize Cost Allocation Tags
2. Be Careful of Lambda Infinite Loops
3. Take Advantage of Savings Plans
4. Optimize Lambda Memory Size
5. Understand Step Function Costs
Monitoring AWS Lambda Costs
Costless offers a simple yet powerful way to monitor all of your AWS Serverless costs, including Lambda. Click here to try Costless for free.
Frequently Asked Questions
Is AWS Lambda cheaper than EC2?
This depends on your workload and traffic volume, but often Lambda is much cheaper than EC2, especially if you have spiky and unpredictable traffic patterns. When you account for total cost of ownership, including development and maintenance costs, Lambda is often significantly cheaper than EC2.
Is AWS Lambda free?
AWS Lambda has a generous free tier that includes 1 million requests and 400,000 GB-seconds of compute time per month.
Is AWS Lambda expensive?
With AWS Lambda, you only pay for the compute you use. Depending on usage Lambda can range from free to quite expensive.
Lambda vs Fargate – What’s the cost difference?
Fargate pricing works similarly to Lambda in that it is pay-per-use, however with Fargate you are charged based on virtual CPU per hour as well as GB/hour. With Fargate you also charged for the time it takes to download your container image. This can vary widely based on the container image you are running. Here is more documentation on Fargate pricing.
ECS vs Lambda cost – What’s the difference?
Unlike Lambda, Elastic Container Service (ECS) pricing is based on the infrastructure that is being managed with ECS. That will be either EC2 or Fargate. Here is more documentation on ECS pricing.