You dont have javascript enabled! Please enable it! Quick Guide To AWS Lambda Pricing - CHARBEL NEMNOM - MVP | MCT | CCSP | CISM - Cloud & CyberSecurity

Quick Guide to AWS Lambda Pricing

6 Min. Read

Understanding AWS Lambda Pricing is essential for effectively managing the costs associated with serverless computing on Amazon Web Services (AWS). AWS Lambda offers a pay-as-you-go pricing model, where you only pay for the compute resources consumed by your functions.

In this article, we’ll delve into the various factors that influence AWS Lambda costs, explore pricing examples and scenarios, and discuss strategies for optimizing Lambda costs to ensure cost-effectiveness and efficiency in your serverless applications.

What Is AWS Lambda?

AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services (AWS). It is a compute service that lets you run code without provisioning or managing servers. Lambda runs your code only when needed and scales automatically, from a few daily requests to thousands per second.

What Is AWS Lambda?
What Is AWS Lambda?

With AWS Lambda, you only pay for the compute time you consume. There are no charges when your code is not running, making it a cost-effective solution. You can run code for virtually any type of application or backend service, and Lambda takes care of everything required to run and scale your code with high availability.

AWS Lambda Cost Factors

Here are the main factors that impact your AWS Lambda costs:

AWS Lambda Cost Factors
AWS Lambda Cost Factors

Invocation Count

The first factor that affects the AWS Lambda pricing is the number of times your functions are invoked. In other words, every time a function is triggered, you are billed. This could be anything from a file upload to an HTTP request from a user. This cost might seem negligible at first, but considering the potential scale of requests, it can add up quickly.

Execution Duration

The second cost factor is the execution duration. AWS calculates this from the time your code begins executing until it returns or otherwise terminates. It’s measured in milliseconds and rounded up to the nearest 1ms. The longer your function runs, the more you pay.

Memory Allocation

Another significant cost factor is the amount of memory you allocate to your functions. AWS Lambda allows you to choose the amount of memory your function requires, and you’re billed based on the amount of memory allocated. More memory means faster execution, but it also means a higher cost.

Networking and Other Services

Lastly, the cost of networking and other AWS services can also affect the overall AWS Lambda pricing. Data transfer out is charged separately and is not included in the free tier. Additionally, if your Lambda function leverages other AWS services, such as S3 or DynamoDB, those costs will be added to your bill separately.


Concurrency in AWS Lambda refers to the number of instances of your function processing events at any given time. AWS Lambda automatically scales the function in response to incoming events. However, the service limits the total concurrent executions across all functions within a given region.

If your application requires higher or more consistent performance, you can manage concurrency by setting reserved concurrency limits or using provisioned concurrency, which incurs additional costs. Provisioned concurrency ensures a specified number of function instances are always ready to respond immediately, which is ideal for high-traffic applications and can prevent Lambda cold starts.

AWS Lambda Pricing Examples and Scenarios

Let’s look into some examples and scenarios to understand better how AWS Lambda pricing works:

Pricing Examples and Scenarios
Pricing Examples and Scenarios

Simple Function Example

Let’s begin with the simplest scenario – running a function that executes in less than a second and is called a few times daily.

Assume that you have a function that takes 500 milliseconds to run and uses 128MB of memory. If this function is invoked 30 times a day, how much would it cost you in a month?

The pricing of AWS Lambda is based on two factors: the amount of memory allocated to your function and the time it takes for your function to execute. The cost for the memory allocation is $0.00001667 for every GB-second. The GB-second is calculated by multiplying the memory size in GB by the function duration in seconds.

In our example:

  • The memory allocation (128MB) is equal to 0.125GB.
  • If the function runs for 0.5 seconds, the GB-seconds for one execution would be 0.125GB * 0.5 sec = 0.0625 GB-seconds.
  • If the function is invoked 30 times a day, the total GB-seconds for the day would be 0.0625 GB-seconds * 30 = 1.875 GB-seconds.
  • Therefore, the cost for a month (30 days) would be 1.875 GB-seconds * 30 days * $0.00001667 per GB-second = $0.000938.

High-Frequency Invocation Example

Now, let’s consider a scenario where a function is invoked frequently.

Suppose you have an application that uses AWS Lambda to resize images. This function takes 2 seconds to run and uses 1024MB (1GB) of memory. The function is invoked 1,000 times per hour. How much would it cost you in a month?

  • The GB-seconds for one execution would be 1GB * 2 sec = 2 GB-seconds.
  • If the function is invoked 1,000 times per hour, the total GB-seconds for the hour would be 2 GB-seconds * 1,000 = 2,000 GB-seconds.
  • Since there are 24 hours in a day and 30 days in a month, the total GB-seconds for the month would be 2,000 GB-seconds * 24 * 30 = 1,440,000 GB-seconds.
  • Therefore, the cost for a month would be 1,440,000 GB-seconds * $0.00001667 per GB-second = $24.

Long Duration Execution Example

Lastly, let’s consider a scenario where a function runs for a long duration.

Suppose you have a data processing function that takes 15 minutes (900 seconds) to run and uses 2048MB (2GB) of memory. This function is invoked once every hour. How much would it cost you in a month?

  • The GB-seconds for one execution would be 2GB * 900 sec = 1,800 GB-seconds.
  • If the function is invoked once every hour, the total GB-seconds for the day would be 1,800 GB-seconds * 24 = 43,200 GB-seconds.
  • Therefore, the total GB-seconds for the month would be 43,200 GB-seconds * 30 = 1,296,000 GB-seconds.
  • The cost for a month would be 1,296,000 GB-seconds * $0.00001667 per GB-second = $21.60.

AWS Lambda Cost Optimization Strategies

Let’s discuss effective cost optimization strategies to help you maximize efficiency and minimize expenses in your serverless applications:

Cost Optimization Strategies
Cost Optimization Strategies

Using the AWS Cost Calculator

One of the first steps to optimize your AWS Lambda cost is using the AWS Cost Calculator. This tool allows you to estimate your AWS bill more accurately by considering your specific use cases and workload requirements. You can input various parameters such as memory allocation, execution time, and the number of requests, and the calculator will estimate your monthly costs.

The AWS Cost Calculator can also provide insights into potential cost savings. For instance, you might discover that reducing your execution time or decreasing your memory allocation could significantly lower your costs. It’s important to regularly review and adjust these parameters according to your application’s needs to ensure you’re not paying for unnecessary resources.

Related: AWS Cost Management Tips and Tricks.

Tuning Memory Allocation

Memory allocation is a significant factor in AWS Lambda Pricing. AWS Lambda allocates CPU power, network bandwidth, and disk I/O in proportion to the amount of memory configured. This means that by adjusting the memory size, you can control the cost and performance of your Lambda functions.

However, it’s essential to strike a balance when tuning memory allocation. While allocating more memory can speed up execution time, it can also increase costs. Conversely, allocating less memory can reduce costs but may result in longer execution times. Therefore, you should monitor your Lambda function’s performance and cost over time and adjust the memory allocation accordingly.

Reducing Execution Time

Reducing the execution time of your Lambda functions is another effective way to optimize AWS Lambda Pricing. AWS charges for the compute time you consume, rounded up to the nearest 100ms. Therefore, even minor reductions in execution time can result in significant cost savings.

There are several ways to reduce execution time, such as optimizing your code for performance, using faster runtimes, and reducing the complexity of your functions. Also, consider using AWS X-Ray to analyze and debug your serverless functions. X-Ray provides insights into your function’s behavior, helping you identify bottlenecks and optimize your code for faster execution.

Managing Invocation Patterns

Another critical aspect of AWS Lambda cost optimization is managing invocation patterns. The way your Lambda functions are invoked can significantly impact the cost. There are two types of invocation patterns: synchronous and asynchronous.

Synchronous invocations wait for the function to complete and return a response, while asynchronous invocations do not wait for the function to finish. Asynchronous invocations can reduce costs by allowing your function to process multiple requests simultaneously, thus reducing the execution time.

Leveraging Reserved Concurrency for Cost Predictability

AWS Lambda allows you to set a reserved concurrency limit for your functions. This feature enables you to allocate a specific number of execution environments for a function, ensuring it has the necessary resources to execute when invoked.

Reserved concurrency can help you manage your costs by providing predictability. By setting a limit on the number of concurrent executions, you can control the maximum cost of your Lambda functions. However, it’s important to remember that setting too low a limit can throttle your functions while setting too high a limit can lead to unnecessary costs.


Understanding AWS Lambda Pricing and implementing cost optimization strategies are key to managing your serverless costs effectively.

By leveraging tools like the AWS Cost Calculator, tuning your memory allocation, reducing execution time, managing invocation patterns, and leveraging reserved concurrency, you can optimize your AWS Lambda costs and get the most value out of your serverless applications.

Thank you for reading my blog.

If you have any questions or feedback, please leave a comment.

-Charbel Nemnom-

Photo of author
About the Author
Charbel Nemnom
Charbel Nemnom is a Senior Cloud Architect with 21+ years of IT experience. As a Swiss Certified Information Security Manager (ISM), CCSP, CISM, Microsoft MVP, and MCT, he excels in optimizing mission-critical enterprise systems. His extensive practical knowledge spans complex system design, network architecture, business continuity, and cloud security, establishing him as an authoritative and trustworthy expert in the field. Charbel frequently writes about Cloud, Cybersecurity, and IT Certifications.

Update Microsoft Sentinel Analytics Rules at Scale

Import Free TAXII Threat Intelligence Feed to Microsoft Sentinel


Let us know what you think, or ask a question...