AWS Lambda Pricing Breakdown: Ultimate Guide 2024
Introduction
AWS Lambda is a serverless compute service that runs your code without the need for managing servers. It’s billed based on the number of requests, the duration of code execution, and a few additional factors—allowing you to pay only for what you use. In this post, we’ll break down the key components of Lambda’s pricing model to help you understand its cost structure in more depth.
Lambda Free Tier
AWS Lambda’s free tier is designed to support low-traffic applications or allow for testing at no cost. Each month, the free tier includes:
- 1 million requests for Lambda functions.
- 400,000 GB-seconds of compute time, applicable to both x86 and Graviton2 processors (ARM)
- 100 GiB of HTTP response streaming, with the first 6MB per request free.
For usage beyond these limits, Lambda offers tiered pricing and additional savings through AWS Compute Savings Plans. By committing to a consistent usage level for one or three years, these plans can offer up to 17% savings on duration and Provisioned Concurrency costs.
General Lambda Pricing
AWS Lambda pricing is influenced by the architecture (x86 or ARM) and the duration of code execution.
The following pricing details are based on the US East (N. Virginia) region.
Lambda charges for:
- Duration: The time your code takes to run, measured in GB-seconds.
- Architecture: Lambda functions can run on x86 or Arm processors, with Arm (Graviton2) offering lower per-second costs.
For each architecture, there are tiered pricing levels based on the total GB-seconds used per month:
AWS Lambda ARM vs x86 Pricing
x86 Pricing
- First 6 Billion GB-seconds per month: $0.0000166667 per GB-second
- Next 9 Billion GB-seconds per month: $0.000015 per GB-second
- Over 15 Billion GB-seconds per month: $0.000013334 per GB-second
ARM Pricing
- First 7.5 Billion GB-seconds per month: $0.0000133334 per GB-second
- Next 11.25 Billion GB-seconds per month: $0.0000120001 per GB-second
- Over 18.75 Billion GB-seconds per month: $0.0000106667 per GB-second
Request Charges (for both architectures): $0.20 per 1 million requests.
The pricing structure depends on the amount of memory allocated to the function. Memory can be set from 128 MB up to 10,240 MB, in increments of 1 MB. The cost per millisecond of execution time increases with memory size:
Here are a few memory-based pricing examples; a more detailed breakdown for each memory size is available here.
x86 Memory-Based Duration Pricing
- 128 MB: $0.000000021 per ms
- 512 MB: $0.000000083 per ms
- 1024 MB: $0.000000167 per ms
- 10,240 MB: $0.000001667 per ms
Arm Memory-Based Duration Pricing
- 128 MB: $0.000000017 per ms
- 512 MB: $0.000000067 per ms
- 1024 MB: $0.000000133 per ms
- 10,240 MB: $0.000001333 per ms
Lambda pricing tiers for duration apply to aggregate monthly usage across all functions within the same account, region, and architecture (x86 or ARM).
Lambda Ephemeral Storage Pricing
AWS Lambda’s ephemeral storage pricing is based on the additional storage allocated and the function’s execution duration. Here’s how it works:
- Each Lambda function includes 512 MB of ephemeral storage at no additional cost.
- You can allocate up to 10,240 MB of additional storage, in 1 MB increments, for both x86 and Arm architectures.
- Pricing for additional storage beyond the free 512 MB:
- $0.0000000309 per GB-second in the US East (N. Virginia) region.
You are only billed for the extra storage you configure, and charges are based on the actual duration of function execution.
Pricing Example: Food Ordering App
Assume you’re a mobile app developer creating a food ordering app with a serverless backend on AWS Lambda to handle variable demand. Here’s a breakdown of charges based on expected usage.
Assumptions:
- Requests: 3 million per month
- Execution Duration: 120 ms per request
- Memory Configuration: 1536 MB (x86 processor)
Charges Breakdown:
- Compute Charges
- Price: $0.0000166667 per GB-second
- Total compute: 540,000 GB-s
- Free tier: 400,000 GB-s
- Billable GB-s: 140,000 GB-s
- Compute charges: 140,000 * $0.0000166667 = $2.33
- Request Charges
- Price: $0.20 per million requests
- Free tier: 1 million requests
- Billable requests: 2 million
- Request charges: 2M * $0.20 / 1M = $0.40
Total Monthly Charges:
- Total = Compute charges + Request charges
- Total cost: $2.33 + $0.40 = $2.73 per month
Lambda Provisioned Concurrency Pricing
Provisioned Concurrency keeps your Lambda functions initialized and ready to respond instantly, which is useful for applications requiring low-latency responses. When enabled, you are billed based on the amount of concurrency configured, the memory allocated, and the function's execution duration. Note that the Lambda free tier does not apply to functions with Provisioned Concurrency.
Charges for Provisioned Concurrency are based on the following:
- Provisioned Concurrency: Billed from the time you enable it until you disable it, rounded up to the nearest five minutes.
- Duration: Calculated from the time your code begins executing until it terminates, rounded up to the nearest millisecond. Charges apply to both handler and initialization code.
- Requests: Standard request pricing applies.
Here’s a breakdown of pricing for US East (N. Virginia):
x86 Architecture
- Provisioned Concurrency: $0.0000041667 per GB-second
- Duration: $0.0000097222 per GB-second
- Requests: $0.20 per 1 million requests
Arm Architecture
- Provisioned Concurrency: $0.0000033334 per GB-second
- Duration: $0.0000077778 per GB-second
- Requests: $0.20 per 1 million requests
If your function exceeds the configured concurrency, additional executions will be billed at the standard rates outlined in the general Lambda pricing. Provisioned Concurrency can be enabled on functions running both x86 and Arm architectures.
Pricing Example: Lambda Provisioned Concurrency
Imagine you’re a retailer running a large sale on Cyber Monday, with increased customer support requests through a mobile app. You deploy an NLP model (e.g., BERT) using AWS Lambda with Provisioned Concurrency to handle the high traffic and ensure fast response times.
Assumptions:
- Requests: 2 million over 24 hours
- Execution Duration: 280 ms
- Memory Configuration: 4096 MB (x86 processor)
- Provisioned Concurrency: 7 instances
Charges Breakdown:
- Provisioned Concurrency Charges
- Price: $0.0000041667 per GB-second
- Provisioned duration: 86,400 seconds
- Concurrency configured: 28 GB (7 * 4096 MB)
- Provisioned Concurrency charges: 2,419,200 GB-s * $0.0000041667 = $10.08
- Compute Charges while Provisioned Concurrency is enabled
- Price: $0.0000097222 per GB-second
- Compute duration: 560,000 seconds (2M requests * 280 ms)
- Total compute: 2,240,000 GB-s
- Compute charges: 2,240,000 GB-s * $0.0000097222 = $21.78
- Request Charges
- Price: $0.20 per million requests
- Total requests: 2 million
- Request charges: $0.40
Total Charges:
- Total = Provisioned Concurrency charges + Compute charges + Request charges
- Total cost: $10.08 + $21.78 + $0.40 = $32.26
Lambda HTTP Response Stream Pricing
AWS Lambda supports HTTP response streaming, allowing functions to return large payloads and improve Time to First Byte performance. You can use HTTP response streaming through the InvokeWithResponseStream
API or a function URL in ResponseStream
mode.
Pricing details:
- First 6 MB per request: Free
- Additional data: $0.008 per GB
With HTTP response streaming, you’re only charged for data beyond the initial 6 MB per request. This pricing structure enables efficient handling of larger responses, optimizing both performance and cost.
Pricing Example: Streaming Server-Side Rendered Web Content
Suppose you’re a developer building a server-side rendered web application with Lambda. To optimize load times, you enable HTTP response streaming, allowing content to be sent as soon as it’s generated.
Let’s assume:
- Requests: 3 million per month
- Compute Duration: 500 ms per request
- Memory Configuration: 1536 MB (x86 processor)
- Payload Size: 100 KB for the first 2 million requests; 7 MB for the last 1 million requests
- Region: US East (N. Virginia)
Monthly Charges Breakdown:
- Compute Charges
- Compute usage: 2,250,000 GB-s
- Free tier: 400,000 GB-s
- Billable GB-s: 1,850,000
- Cost: $30.83
- Request Charges
- Billable requests (after free tier): 2 million
- Cost: $0.40
- Processed Bytes Charges
- First 6 MB per request free; 190.7 GB free tier covered
- Chargeable bytes: 976.56 GB
- Cost: $7.81
Total Monthly Cost: $39.04
Data Transfer & Other Charges
AWS Lambda charges for data transfer in and out of functions, as well as for certain integrations and configurations. Here’s a breakdown:
- Data Transfer: Data transferred in and out of AWS Lambda from outside the function's region incurs charges based on EC2 data transfer rates.
- Free In-Region Transfers: Data transfer within the same AWS region is free for certain services, including:
- Amazon S3, Glacier, DynamoDB, SES, SQS, Kinesis, ECR, SNS, EFS, and SimpleDB.
- VPC and VPC Peering Charges: If Lambda functions are configured within an Amazon Virtual Private Cloud (VPC) or involve VPC peering, additional charges may apply as per EC2 on-demand pricing.
Additional Charges
You may incur extra costs if your Lambda function interacts with other AWS services or transfers data, such as:
- S3 Data Access: Any read or write operations between Lambda and S3 are billed based on S3 request and data transfer costs.
For a comprehensive view of data transfer costs, refer to the pricing details of each relevant AWS service.
Lambda@Edge Pricing
Lambda@Edge, a feature of Amazon CloudFront, allows you to run code closer to your users, enhancing performance and reducing latency. Charges for Lambda@Edge are based on requests and execution duration, applied globally.
- Requests: $0.60 per 1 million requests ($0.0000006 per request).
- Duration: $0.00005001 per GB-second. Duration is calculated from the start of code execution to termination, measured in 1 ms increments. For example, with 128 MB memory allocated, the duration cost is $0.00000625125 per 128 MB-second.
These charges apply to the total number of requests across all functions triggered by CloudFront events worldwide.
Pricing Example: Lambda@Edge
Assume your Lambda@Edge function executes 10 million times in a month, with each execution lasting 10 ms. Here’s how the charges are calculated:
- Compute Charges
- Compute duration: 100,000 seconds (10M requests * 0.01 seconds)
- Cost per 128MB-second: $0.00000625125
- Monthly compute charges: 100,000 * $0.00000625125 = $0.63
- Request Charges
- 10 million requests at $0.60 per million
- Monthly request charges: 10M * $0.60 / 1M = $6.00
Total Monthly Charges:
- Total = Compute charges + Request charges = $0.63 + $6.00 = $6.63 per month
Conclusion
AWS Lambda’s pricing model provides flexibility for a range of applications, from low-traffic experiments to high-demand workloads. By understanding the core components—compute, requests, storage, Provisioned Concurrency, and data transfer—developers can optimize both cost and performance.
The Lambda Free Tier offers a good starting point, while tiered pricing and Compute Savings Plans help reduce costs for higher usage. Options like Arm processors and Provisioned Concurrency enable further cost efficiency and low-latency responses when needed.