AWS Lambda, a serverless computing indulgence handed over by Amazon Web Services, allows developers to run code without provisioning or managing servers. Lambda executes code in reaction to triggers analogous to changes in data, system country, or user conduct, automatically managing the compute resources demanded by that code.
One of the pivotal advantages of utilizing AWS Lambda is its pricing model, which offers a cost-operative expressway to make and emplace operations.
Elements of AWS Lambda Pricing
AWS Lambda pricing is based on three primary factors: request pricing, duration pricing, and fresh costs for voluntary features such as provisioned concurrency and data transfer. Let's explore each element in detail.
Request Pricing
AWS Lambda charges for the number of requests your functions admit. Each time you create a function, it counts as a request. AWS Lambda includes a free bracket of 1 million requests per month. Beyond the free bracket, the cost is$0.20 per 1 million requests.
Suppose you have a Lambda function configured with 512 MB of mind that executes 10 million moments monthly, with a moderate execution time of 200 milliseconds (0.2 seconds).
Total requests=10,000,000
Free tier=1,000,000
Billable requests=10,000,000−1,000,000=9,000,000
Request cost=9,000,000×$0.20/1,000,000=$1.80
Duration Pricing
Duration is calculated from when your code begins executing until it returns or terminates, rounded to the nearest one millisecond. The duration price depends on the quantum of memory allocated to the function. AWS Lambda offers several memory configurations ranging from 128 MB to 10,240 MB. The formula for calculating duration pricing is
Duration cost = Memory( GB) × Execution time( seconds) × Rate The rate for 1 GB- second is $0.0000166667
For example
Memory configuration=512 MB=0.5 GB
Execution time per request=0.2 seconds
Total duration=10,000,000×0.2 seconds=2,000,000 seconds=555.56 hours
Billable duration (GB-seconds)=0.5×2,000,000=1,000,000 GB-seconds
Duration cost=1,000,000×$0.0000166667=$16.67
Provisioned Concurrency Pricing
Provisioned Concurrency is a voluntary point that keeps your functions initialized and ready to respond in double-figure milliseconds. This point can be helpful for operations that require predictable latency. The cost for Provisioned Concurrency includes an hourly rate and a duration rate.
Provisioned Concurrency$0.0000041667 per GB-alternate
Provisioned Concurrency execution duration$0.0000133334 per GB-alternate
Additional Costs
Further charges may apply based on your use case and configuration, similar to data transfer charges and charges for utilizing other AWS services (e.g., API Gateway, S3, DynamoDB).
AWS Lambda Pricing
Pricing Component | Free Tier | Paid Tier | Rate |
Request | 1 million requests per month | Beyond Free Tier | $0.20 per 1 million requests |
Duration | NA | - | $0.0000166667 per GB-second |
Provisioned Concurrency | NA | - | $0.0000041667 per GB-second |
Provisioned Concurrency Duration | NA | - | $0.0000133334 per GB-second |
Data Transfer | NA | Charged as per AWS Data Rates | Varies by region and amount of data |
AWS Lambda Pricing Based on Region
Region | Requests (per million) | Duration (per GB-second) | Free Tier (per month) |
---|---|---|---|
US East (N. Virginia) | $0.20 | $0.00001667 | 1 million requests, 400,000 GB seconds |
US West (Oregon) | $0.20 | $0.00001667 | 1 million requests, 400,000 GB seconds |
EU (Ireland) | $0.20 | $0.00001667 | 1 million requests, 400,000 GB seconds |
Asia Pacific (Sydney) | $0.23 | $0.00001967 | 1 million requests, 400,000 GB seconds |
Asia Pacific (Tokyo) | $0.23 | $0.00001967 | 1 million requests, 400,000 GB seconds |
South America (São Paulo) | $0.24 | $0.00002100 | 1 million requests, 400,000 GB seconds |
Calculate Your Pricing with a Calculator
Factors Affecting AWS Lambda Pricing
Several factors can influence the total cost of using AWS Lambda, including:
Function Memory Allocation
The quantity of memory you allow to your Lambda function directly affects the cost. Further memory results in advanced charges but can also improve interpretation and reduce execution time.
Execution Time
The duration for which your Lambda function runs impacts the typical cost. Optimizing your code to run more efficiently can support reduced implementation time and charges.
Number of Requests
The more constantly your function is invoked, the more advanced the request charges will be. Monitoring and managing incantation frequency is essential for cost control.
Provisioned Concurrency
However, utilizing provisioned concurrence can ensure that your functions are invariably ready to apply, but this comes at a fresh cost if you require predictable interpretation.
Data Transfer
Nevertheless, data transfer charges may apply If your Lambda function interacts with other AWS services or alien endpoints. Understanding these charges is pivotal for budgeting.
Cost Comparison of AWS Lambda with Azure Functions and Google Cloud
Feature | AWS Lambda | Traditional Server-Based | Azure Functions | Google Cloud Functions |
---|---|---|---|---|
Pricing Model | Pay-per-use (requests and compute time) | Fixed costs (server hardware, maintenance) | Pay-per-use (executions and runtime) | Pay-per-use (invocations and execution time) |
Compute Time Cost | $0.00001667 per GB-second | Varies (cost of physical/virtual servers) | $0.000016 per GB-second | $0.0000025 per GB-second |
Request Cost | $0.20 per 1M requests | N/A | $0.20 per 1M executions | $0.40 per 1M invocations |
Scalability | Automatic | Manual scaling needed | Automatic | Automatic |
Maintenance | None (managed by AWS) | Full responsibility (hardware/software updates) | None (managed by Azure) | None (managed by Google) |
Cold Start Latency | Yes (milliseconds to seconds) | N/A | Yes (milliseconds to seconds) | Yes (milliseconds to seconds) |
Integration | Seamless with AWS ecosystem | Requires custom integration | Seamless with Azure services | Seamless with Google Cloud services |
Popular Use Cases | Microservices, real-time data processing | Any long-running application | Event-driven tasks, HTTP triggers | Event-driven tasks, HTTP triggers |
Free Tier | 1M requests and 400,000 GB seconds per month | N/A | 1M executions and 400,000 GB seconds per month | 2M invocations and 400,000 GB seconds per month |
AWS Lambda Cost Optimization by Execution Time
Cost Optimization Techniques
If you want to optimize the cost of AWS Lambda, you must consider the following strategies:
Right-Sizing Memory Allocation
Start with the lowest memory allocation that meets your performance needs and adjust as necessary. AWS Lambda provides detailed criteria to help you understand the optimal mind configuration.
Optimize Code Efficiency
Effective code can reduce implementation time, which in turn lowers duration charges. Profiling and optimizing your code can result in significant cost savings.
Use Free Tier
Take advantage of the AWS Lambda free category, which provides 1 million free queries and 400,000 GB-seconds of computing time per month. This can significantly reduce charges for low—to moderate-operations.
Implement Request Batching
Nonetheless, account batching queries reduce the number of function invocations if your operation permits some latency.
Monitor and Analyze Usage
Regularly reconsider your Lambda operation and charges using AWS Cost Explorer and AWS CloudWatch. Correlating operation patterns and exceptions can help optimize resource allocation and reduce charges.
Consider Reserved Concurrency
However, reserved concurrence can save costs compared to on-demand provisioned concurrence if you have predictable operation patterns.
AWS EC2 Pricing Vs AWS Lambda Pricing?
Service | Pricing Model | Example Cost (per month) | Use Case |
---|---|---|---|
AWS Lambda | Pay-per-use | $0.20 per 1M requests + $0.00001667 per GB-second | Cost-effective for intermittent, short-duration tasks. |
AWS EC2 | On-Demand | t2.micro: $8.34, m5.large: $70.08 | Suitable for sustained, long-running processes or specific hardware needs. |
Key Points:
- AWS Lambda: Ideal for functions that are invoked intermittently and do not run continuously.
- AWS EC2: Best for applications requiring consistent availability.
Commands for AWS Lambda
Command | Description |
---|---|
| Creates a new Lambda function. |
| Deletes an existing Lambda function. |
| Updates the code for an existing Lambda function. |
| Updates the configuration settings for an existing Lambda function. |
| Lists all Lambda functions in the AWS account. |
| Retrieves configuration details for a specific Lambda function. |
| Invokes a Lambda function synchronously. |
| Invokes a Lambda function asynchronously. |
| Lists all aliases for a specific Lambda function. |
| Creates a new alias for a specific Lambda function. |
| Updates an existing alias for a specific Lambda function. |
| Deletes an alias for a specific Lambda function. |
| Lists all event source mappings for a specific Lambda function. |
| Creates a new event source mapping for a specific Lambda function. |
| Updates an existing event source mapping for a specific Lambda function. |
| Deletes an event source mapping for a specific Lambda function. |
| Lists all tags associated with a specific Lambda function. |
| Adds tags to a specific Lambda function. |
| Removes tags from a specific Lambda function. |
| Publishes a new version of a specific Lambda function. |
| Lists all versions of a specific Lambda function. |
| Lists all versions of a specific Lambda layer. |
| Publishes a new version of a specific Lambda layer. |
| Grants permission to another AWS account to use a specific version of a Lambda layer. |
| Revokes permission from another AWS account to use a specific version of a Lambda layer. |
| Retrieves information about a specific version of a Lambda layer. |
| Deletes a specific version of a Lambda layer. |
Summing Up AWS Lambda Pricing
AWS Lambda offers an adjustable and cost-operative serverless computing option with a pricing model that scales with the operation. This model includes several crucial factors: requests, duration, provisioned concurrence, and fresh charges similar to data transfer. Requisition pricing charges for the number of function invocations, while duration pricing is based on the mind distribution and the execution time of each invocation. Provisioned concurrence, a voluntary point, ensures places are invariably ready to respond snappily but comes with its charges.
To further control charges, employing strategies like right-sizing memory allocation and optimizing code effectiveness is essential. Starting with the lowest necessary memory allocation and conforming based on interpretation metrics can reduce gratuitous charges. Also, authoring effective code can drop execution time and lower duration charges. Using AWS Lambda’s free tier, which provides a physical quantum of free operation each month, can also contribute to significant savings for low to moderate workloads.
Read More
https://devopsden.io/article/heroku-vs-aws
Follow us on
Table of Contents