AWS Lambda Pricing Calculator
Estimate your AWS Lambda costs by inputting your expected usage. Our calculator helps you understand the pricing model based on requests, duration, memory, and data transfer.
AWS Lambda Cost Estimator
Number of times your Lambda function is invoked.
Average execution time of your function in milliseconds.
Memory allocated to your Lambda function. Affects compute power and cost.
AWS Lambda offers 1 million free requests per month.
AWS Lambda offers 400,000 GB-seconds free per month.
Data transferred out from AWS regions to the internet in GB. AWS internal data transfer is generally free.
Estimated Monthly Cost
$0.00
$0.00
$0.00
$0.00
Cost = (Prorated Request Cost) + (Prorated Compute Cost) + (Data Transfer Cost)
Compute Cost (GB-seconds)
Monthly cost breakdown by requests and compute time.
| Region | Request Price (per 1M requests) | Compute Price (per 1 GB-second) | Free Tier (Requests) | Free Tier (GB-seconds) |
|---|---|---|---|---|
| us-east-1 (N. Virginia) | $0.20 | $0.0000166667 | 1,000,000 | 400,000 |
| us-west-2 (Oregon) | $0.20 | $0.0000166667 | 1,000,000 | 400,000 |
| eu-central-1 (Frankfurt) | $0.22 | $0.0000186667 | 1,000,000 | 400,000 |
What is AWS Lambda Pricing?
AWS Lambda pricing is a pay-per-use model that charges you only for the compute time you consume. Unlike traditional server hosting where you pay for idle time, Lambda allows you to scale automatically and pay only when your code is running. The core components of Lambda pricing are the number of requests (invocations) and the duration your code executes, measured in gigabyte-seconds (GB-seconds). AWS also provides a generous free tier, which significantly reduces costs for many applications with low to moderate usage. Understanding these components is crucial for accurately estimating your AWS Lambda costs and optimizing your serverless architecture.
Who should use it: Developers and organizations building or migrating to serverless applications, microservices, event-driven architectures, background processing tasks, and APIs. Anyone looking to reduce operational overhead and pay only for actual compute consumption will find Lambda pricing attractive. It’s particularly beneficial for workloads with variable traffic patterns, as you don’t overprovision resources.
Common misconceptions: A frequent misunderstanding is that Lambda is “free” because of the free tier. While the free tier is substantial, exceeding its limits incurs costs. Another misconception is that cost is solely determined by execution time; the amount of memory allocated per function significantly impacts the GB-second metric and thus the cost. Finally, many overlook the cost associated with data transfer out of AWS regions, which can add up for applications serving large amounts of data externally.
AWS Lambda Pricing Formula and Mathematical Explanation
The AWS Lambda pricing model is designed to be straightforward, charging based on usage. The primary cost drivers are function requests and compute time (memory * duration). Data transfer out also contributes to the final cost.
Core Calculation Breakdown:
- Request Costs: You are charged a small fee for every request (invocation) made to your Lambda function.
-
Compute Costs: This is calculated based on the duration your function runs multiplied by the memory allocated to it. The unit is Gigabyte-seconds (GB-seconds).
- Duration is measured in milliseconds (ms) and converted to seconds.
- Memory is selected in megabytes (MB) and converted to Gigabytes (GB).
- Formula: Compute Cost = (Number of Requests) * (Duration in Seconds) * (Memory in GB) * (Price per GB-second)
- Data Transfer Costs: Data transferred out from Lambda to the internet incurs a cost per GB. Data transfer within the same AWS region is generally free.
- Free Tier Application: AWS provides a monthly free tier for requests and GB-seconds. These are applied automatically before calculating the final billable amount.
The Simplified Calculator Formula:
Total Monthly Cost = (Billable Requests Cost) + (Billable Compute Cost) + (Data Transfer Cost)
Where:
- Billable Requests Cost = MAX(0, (Total Requests – Free Tier Requests) / 1,000,000) * (Price per 1M Requests)
- Billable Compute Cost = MAX(0, (Total Requests * Duration in Seconds * Memory in GB) – Free Tier GB-seconds) * (Price per GB-second)
- Data Transfer Cost = (Data Transfer Out in GB) * (Price per GB)
Variables Table:
| Variable | Meaning | Unit | Typical Range / Values |
|---|---|---|---|
| Requests per Month | Total number of times Lambda functions are invoked. | Count | 100 – 1 Billion+ |
| Average Duration (ms) | Average execution time for a single function invocation. | Milliseconds (ms) | 1 – 15,000 (max 15 min) |
| Memory Allocated | Amount of memory assigned to the Lambda function. Influences CPU allocation. | Megabytes (MB) | 128 MB – 10,240 MB |
| Data Transfer Out (GB) | Amount of data transferred from AWS to the internet. | Gigabytes (GB) | 0.1 GB – 1000+ GB |
| Price per 1M Requests | Cost for one million function invocations. | USD ($) | ~$0.20 |
| Price per GB-second | Cost for one Gigabyte of memory used for one second. | USD ($) | ~$0.0000166667 |
| Price per GB (Data Transfer) | Cost for transferring one Gigabyte of data out of AWS. | USD ($) | ~$0.09 (Varies by region and destination) |
| Free Tier Requests | Complimentary requests per month. | Count | 1,000,000 |
| Free Tier GB-seconds | Complimentary compute time (memory * duration) per month. | GB-seconds | 400,000 |
Practical Examples (Real-World Use Cases)
Example 1: A Popular Web API Backend
A startup runs its primary web API using AWS Lambda. The API handles user authentication, data retrieval, and processing for their mobile application.
- Usage:
- Requests per Month: 50,000,000
- Average Duration: 150 ms
- Memory Allocated: 512 MB
- Data Transfer Out: 50 GB
Calculations (Simplified, assuming us-east-1 pricing):
- Requests: 50M requests > 1M free tier. Billable requests = 49,000,000. Cost = (49,000,000 / 1,000,000) * $0.20 = $9,800
- Compute:
- Duration in seconds = 150 ms / 1000 = 0.15 s
- Memory in GB = 512 MB / 1024 = 0.5 GB
- Total GB-seconds = 50,000,000 requests * 0.15 s * 0.5 GB = 3,750,000 GB-seconds
- Billable GB-seconds = 3,750,000 – 400,000 (free tier) = 3,350,000 GB-seconds
- Cost = 3,350,000 * $0.0000166667 = $55.83
- Data Transfer: 50 GB * $0.09/GB = $4.50
- Total Estimated Cost: $9,800 + $55.83 + $4.50 = $9,860.33
Interpretation: This example highlights how request costs dominate when dealing with a high volume of API calls. Optimizing function efficiency (reducing duration) or potentially using provisioned concurrency for predictable high traffic could be considered.
Example 2: A Scheduled Image Resizing Task
A content management system uses Lambda to automatically resize uploaded images on a schedule.
- Usage:
- Requests per Month: 100,000 (triggered by uploads)
- Average Duration: 500 ms
- Memory Allocated: 1024 MB
- Data Transfer Out: 2 GB (to external CDN)
Calculations (Simplified, assuming us-east-1 pricing):
- Requests: 100,000 requests < 1M free tier. Billable requests = 0. Cost = $0.00
- Compute:
- Duration in seconds = 500 ms / 1000 = 0.5 s
- Memory in GB = 1024 MB / 1024 = 1 GB
- Total GB-seconds = 100,000 requests * 0.5 s * 1 GB = 50,000 GB-seconds
- Billable GB-seconds = 50,000 GB-seconds < 400,000 free tier. Cost = $0.00
- Data Transfer: 2 GB * $0.09/GB = $0.18
- Total Estimated Cost: $0 + $0 + $0.18 = $0.18
Interpretation: This user stays well within the free tier limits for both requests and compute. The primary cost is minimal data transfer. This demonstrates the power of Lambda for background tasks that don’t have extremely high throughput or long execution times.
How to Use This AWS Lambda Pricing Calculator
- Input Your Usage: Enter your estimated monthly usage for:
- Requests per Month: How many times your functions will be triggered.
- Average Duration per Request (ms): The typical execution time in milliseconds.
- Memory Allocated (MB): Select the memory size configured for your functions. Higher memory also means more vCPU power.
- Data Transfer Out (GB): Estimate the amount of data your functions will send to the internet.
- Leverage Defaults: The calculator starts with common default values and includes the standard AWS free tier limits. These free tier inputs are read-only as they are fixed by AWS.
- Review Intermediate Values: Before the final cost, check the calculated costs for requests, compute (GB-seconds), and data transfer. This helps pinpoint where most of your spending might occur.
- Understand the Primary Result: The highlighted main result shows your total estimated monthly cost, considering the free tier.
- Analyze the Chart: The dynamic chart visually breaks down the estimated cost between request charges and compute charges, helping you identify the main cost drivers.
- Examine the Table: The table provides a quick reference for Lambda pricing tiers in different regions and highlights the free tier allowances.
- Make Informed Decisions: Use the results to optimize your Lambda functions (e.g., reduce duration, choose appropriate memory) or adjust your architecture to stay within cost-effective limits.
- Copy Results: Use the “Copy Results” button to easily share your cost estimates or save them for documentation.
Key Factors That Affect AWS Lambda Pricing Results
- Function Invocation Count (Requests): The sheer number of times your Lambda function is triggered is a direct cost driver, especially after exceeding the free tier limit. High-traffic applications will see request costs become significant.
- Execution Duration: Longer running functions consume more compute time. Every millisecond counts towards the GB-second calculation. Optimizing code to run faster directly reduces costs.
- Memory Allocation: This is a crucial setting. While more memory increases cost per GB-second, it also proportionally increases the allocated CPU power. Finding the sweet spot that balances performance and cost is key. A function that needs more CPU might run faster with more memory, potentially reducing overall duration cost.
- AWS Region: Lambda pricing varies slightly between different AWS regions. The cost per GB-second and per million requests can differ, so always check the pricing for your specific deployment region.
- Data Transfer Out: While often overlooked, significant data egress (transferring data from AWS to the internet) can add up. This is particularly relevant for Lambda functions that serve large files or stream data externally.
- AWS Free Tier Usage: Effectively utilizing the free tier is the biggest factor in keeping costs low for small-to-medium applications. The calculator automatically accounts for this, but understanding its limits helps in planning.
- Provisioned Concurrency: While not directly in the basic pricing formula, if you use Provisioned Concurrency to keep functions warm, you pay an additional charge for the duration concurrency is enabled, on top of the request and duration charges when functions execute. This is for predictable high performance needs.
- Architecture Decisions: The overall design of your serverless application impacts costs. For instance, chaining many small Lambda functions might incur more request costs than a single, more complex function. Conversely, a single large function might be inefficient if only parts of its logic are needed for specific events.
Frequently Asked Questions (FAQ)
-
What is the AWS Lambda free tier?
AWS Lambda offers a generous free tier that includes 1 million free requests per month and 400,000 GB-seconds of compute time per month. This applies automatically and significantly reduces costs for many applications. -
How is GB-second calculated?
It’s calculated by multiplying the memory allocated to your function (in GB) by the execution duration of your function (in seconds). For example, a function allocated 512MB (0.5 GB) running for 1 second uses 0.5 GB-seconds. If it runs for 2 seconds, it uses 1.0 GB-second. -
Does Lambda cost anything when my code isn’t running?
No, Lambda follows a true pay-per-execution model. You only pay for the compute time your code consumes (measured in GB-seconds) and the number of requests it receives. There are no charges for idle time. -
How does memory size affect cost?
Memory allocation directly impacts the GB-second calculation. More memory costs more per GB-second, but also provides more CPU power, potentially reducing execution duration. You need to balance these factors. -
Are there hidden costs with AWS Lambda?
The primary “hidden” costs can be data transfer out to the internet, costs associated with other AWS services triggered by Lambda (like API Gateway, SQS, DynamoDB), and potential costs for features like Provisioned Concurrency if used. The core Lambda execution cost itself is transparent. -
Can I optimize my Lambda costs?
Yes, key optimizations include reducing function execution duration through code efficiency, choosing the right memory size, minimizing data transfer out, and architecting efficiently to avoid unnecessary invocations or complex function chains. -
What if my function runs longer than expected?
Lambda functions have a maximum timeout setting (default 3 seconds, max 15 minutes). If a function exceeds its timeout, it’s terminated, and you are billed for the time consumed up to that point. This prevents runaway costs but requires proper error handling. -
How does the calculator handle different AWS pricing tiers?
This calculator uses example pricing for a specific region (us-east-1). AWS Lambda pricing varies slightly by region. Always refer to the official AWS Lambda pricing page for the most accurate and up-to-date costs for your specific region. -
Does the calculator include costs for API Gateway or other services?
No, this calculator focuses solely on AWS Lambda execution costs (requests, compute, data transfer). Integrations like API Gateway, Load Balancers, or other event sources have their own separate pricing structures.
Related Tools and Internal Resources