Table Of Contents
What Does AWS Lambda Do? AWS Lambda Pricing Explained How Does Lambda Billing Work? Lambda Costs: AWS Lambda Pricing Plans And Tiers AWS Lambda Cost Optimization: 6 Tips You Need To Know How To View, Control, And Optimize Your Lambda Costs AWS Lambda Pricing FAQs

AWS Lambda is an event-driven compute service, which means it executes tasks automatically when triggered by a compute event. This automation also means that your Lambda costs can quickly exceed your budget. That is especially true when you’re not familiar with AWS Lambda pricing.

In this guide, we’ll discuss the AWS Lambda pricing model, including how billing works, and how to optimize Lambda costs.

Table of Contents

What Does AWS Lambda Do?

Amazon’s Lambda service enables you to run code for nearly any type of app or backend system without the need to provision or manage servers yourself. You only need to upload your code. AWS Lambda will take care of everything your code requires to run and scale with high availability.

Because it is event-driven, AWS Lambda leverages the concept of Functions. A Lambda function is a piece of Python code (no name when defining it) that performs a specific task. The lambda (function) assesses an expression based on a given argument. You provide the lambda a value (an argument) and then supply the operation (the expression).

That code executes when specific events occur in related AWS services, for example, when an object is added in an Amazon S3 bucket.

Some call this Function-as-a-Service (FaaS). Many refer to this approach as serverless computing.

Every function, or lambda, runs in an isolated environment, complete with its own file system view and resources.

Lambda is useful for a wide range of tasks, such as:

  • Run inconsistent workloads with long pauses between executions over the course of a day
  • Perform real-time data process
  • Support social media streaming together with Amazon Kinesis
  • Operate serverless websites
  • Quickly convert documents into different formats, particularly when their content changes frequently.

If choosing the right resources for your serverless compute requirements is important to you, check out CloudZero Advisor for customized recommendations based on factors such as AWS service, resource type, instance type, region, pricing, and more.

So, how does AWS Lambda charge for its capabilities?

finops-automation-series-thumbnails

AWS Lambda Pricing Explained

AWS Lambda charges you for the serverless compute time you use; the total time it takes your code to execute and the number of requests for your functions. There are no charges when your code is not running.

Once you package your code into Lambda functions, the service will run the function only when triggered. It then scales automatically to meet the compute demand that your workload requires. AWS Lambda can scale from handling a few requests daily to thousands per second.

Here’s how that works during operations.

How Does Lambda Billing Work?

AWS Lambda pricing depends on seven major factors:

  • Number of invoke calls or requests made for a function
  • Execution time measured in milliseconds (and rounded off to the nearest 1 ms)
  • Amount of memory you allocate in Gigabytes (GB)
  • The CPU architecture (X86 or Arm) you use
  • If you take advantage of Compute Savings Plans (which apply to Provisioned Concurrency and to duration)
  • The AWS Lambda ephemeral storage you allocate
  • Whether you use Lambda Provisioned Concurrency

The following formula will help you calculate your AWS Lambda costs in GB-seconds:

Number of executions X (Lambda memory size/1024) X (Lambda duration in milliseconds/1000) = GB-seconds

You can see an illustration of how Lambda calculates your bill from this image:

Bill Calculator

At CloudZero, we are all about breaking down costs to make sense to your business, so you understand what you’re paying for. That’s how you maximize performance and keep costs low without compromising other crucial factors, such as availability. So, in the next section, we’ll help you unravel these Lambda pricing factors in more detail.

1. How does the number of AWS Lambda requests affect pricing?

The Lambda service counts a request from the time it begins to execute in response to an event notification trigger or an invoke call.

An event notification trigger may come from Amazon EventBridge, or the Amazon Simple Notification Service (SNS), while an invoke call may come from the Amazon API Gateway or through the AWS SDK (including test calls from the AWS Console).

A request lasts until it is either returned or terminated. Lambda charges per request or invocation ($/request or invoke call).

  • There is no charge for the first 1 million requests and the first 400,000 GB-seconds of compute time in a month.
  • The free allowance applies to functions running on both Graviton2 (Arm-based) and X86 CPUs.
  • After that, you pay $0.20 per 1 million requests.
Billing Table

The final bill will be for the total number of requests made across all your Lambda functions.

2. How does code execution duration affect AWS Lambda pricing?

Lambda also counts duration from the time your code starts to execute to the moment it returns or terminates, rounded to the nearest one millisecond. Duration pricing is in dollars per hour ($/hour).

  • The free tier provides up to 3.2 million seconds of compute time per month free, and
  • 400,000 GB-seconds of compute time per month free

However, the exact duration price you’ll pay will depend on the amount of memory you’ll allocate to your function (min 128 MB; max 10 240 MB or 1 GB). Here’s what we mean based on prices in the US East (Ohio) region:

Memory amount in MB

Price per 1 millisecond (1 ms) for X86 CPU Architecture

Price per 1 millisecond (1 ms) for Arm CPU Architecture

128

$0.0000000021

$0.0000000017

512

$0.0000000083

$0.0000000067

1024

$0.0000000167

$0.0000000133

1536

$0.0000000250

$0.0000000200

2048

$0.0000000333

$0.0000000267

3072

$0.0000000500

$0.0000000400

4096

$0.0000000667

$0.0000000533

5120

$0.0000000833

$0.0000000667

6144

$0.0000001000

$0.0000000800

7168

$0.0000001167

$0.0000000933

8192

$0.0000001333

$0.0000001067

9216

$0.0000001500

$0.0000001200

10240

$0.0000001667

$0.0000001333

3. How does memory allocation affect AWS Lambda costs?

Your Lambda cost will vary depending on the amount of memory (RAM) you allocate to your function. The previous table shows how pricing changes with changes in allocated memory.

One more thing. The service automatically allocates you a proportional amount of processing power (CPU) and other resources based on the amount of memory you allocate your function. That means increasing your Lambda memory size triggers an equivalent increase in CPU power available to your function.

4. How Does AWS Lambda Ephemeral Storage Pricing Work?

Ephemeral storage pricing starts at $0.0000000309 per GB-second. You can allocate between 512 MB and 10 240 MB of ephemeral storage to your function, and its execution duration (in milliseconds). 512 MB comes complementary and both X86 and ARM architectures are supported.

You only pay extra for additional ephemeral storage, which you can increase in 1 MB increments.

5. How does provisioned concurrency affect AWS Lambda pricing?

Provisioned concurrency is a Lambda feature that seeks to reduce startup latency. When active, provisioned concurrency keeps your functions initialized and ready to respond to requests from your workload in double-digit milliseconds.

Some things to note here are that you:

  • Pay for the level of concurrency you specify, as well as the duration you configure it
  • Both X86 and Arm-based CPUs support Provisioned Concurrency
  • Provisioned Concurrency also charges you for Requests and Duration when it is enabled and executed for your function.
Pricing Table
  • The service calculates PC from the time you enable it on your function to the point in time you disable it, rounded up to the closest five minutes. Price varies with the amount of memory you provide to your function AND the level of concurrency you configure on it.
  • The service calculates Duration starting from the point at which your code begins running until it returns or terminates, and then rounds it to the nearest one millisecond. Price varies with the amount of memory you dedicate to your function.
  • The free tier doesn’t apply to Functions that have Provisioned Concurrency enabled.

There’s just one more billable consideration.

6. Additional AWS Lambda charges

Additional charges may apply for the following:

Data transfer

When data is transferred into and out of AWS Lambda functions from locations outside the region where the function is running, expect charges at the Amazon EC2 data transfer rates below.

Data Transfer in

Using Lambda@Edge

This option enables you to improve performance and reduce latency by running your code closer to your users using AWS CloudFront. Prices are $0.60 per 1 million requests or $0.0000006 per request and $0.00005001 per GB-second you use.

Say you allocate 128 MB of memory for each execution of your Lambda@Edge function. Then your duration cost will be $0.00000625125 per 128 MB-second you use, measured in 1 ms intervals.

Lambda Costs: AWS Lambda Pricing Plans And Tiers

Here are some final thoughts (and hopefully some clarification on the prices discussed in the previous section).

Free tier

Each month, Lambda offers 1 million requests and 400,000 GB-seconds of compute for free. Subtract this free allowance from your monthly total requests and code execution time to calculate your billable balance.

On-Demand

For usage above the free allowance, a $0.20 fee applies per 1 million requests, and a $0.0000000167 fee applies per 1024 MB-second (1 GB-second) of execution time. While pricing for requests is constant, duration pricing will vary based on the amount of memory you allocate to your function. See the chart in “How does code execution duration affect AWS Lambda pricing” above.

Savings plans

With AWS Lambda, you can take advantage of discounted compute rates (up to 17% off) by committing to a certain amount of usage over one or three years. Compute Savings Plans are ideal for consistent workloads and apply to Duration, Duration (with Provisioned Concurrency), and Provisioned Concurrency.

AWS Lambda Cost Optimization: 6 Tips You Need To Know

As you can tell, there are quite a number of factors that affect AWS Lambda pricing. You do not want these to catch you off guard when not paying close attention during account setup and budgeting.

For that reason, here are some tips to look out for to help you control your AWS Lambda costs.

1. If your Lambda function transfers data to or from other AWS services, there are additional charges

If your AWS Lambda requests are involved in any way with a different AWS service, you’ll be charged for both services. The additional charges are based on the prices of the specific AWS services you use. For example, when your functions write to or read data from Amazon S3, you’ll be billed for the requests and any data that’ll be stored in S3.

2. Memory size is configurable

You can set the maximum size of the memory and the maximum execution time for each Lambda function. Your function automatically gets more CPU power the more memory you provide.

3. Decide between X86 and Arm-based CPUs

AWS designed Graviton2 processors based on Arm processor architecture to deliver up to 34% better price performance versus running Lambda functions on x86 processors. Some applicable use cases here include serverless workloads like data and media processing, serverless websites, and mobile backends.

4. You can configure things further

You can specify limitations for the amount of CPU, memory, and storage resources that serverless functions can use. Several resources are subject to these limits, including:

  • Number of concurrent executions
  • Storage for uploaded functions as well as quotas for function configuration
  • Deployment and execution parameters like memory allocation
  • Timeout
  • Environment variables
  • Layers
  • Burst concurrency.

Here’s something else.

5. About the Memory Size (GB) you allocate

You allocate this amount of memory to your function through the AWS console. However, this isn’t actually how much memory the function uses. It follows then that reducing your function’s memory usage without tweaking this configuration may not yield much cost savings.

6. About the Execution time (ms)

Functions take a certain amount of time to execute their code logic. Here is the thing. When a function makes an outgoing call and waits for the response, the Lambda service counts the idle time in-between as part of the function’s execution time.

7. Configure your environment with CloudZero Advisor

Dashboard

CloudZero Advisor provides customized insights about the best resources for your AWS Lambda projects. Among the factors it considers are pricing, AWS services, resource type, and AWS region. You can use CloudZero Advisor to determine whether an X86 or Arm-based CPU is right for your serverless computing, for example. Learn more about CloudZero Advisor here.

How To View, Control, And Optimize Your Lambda Costs

Depending on the size of your operation, calculating AWS Lambda costs can be challenging. AWS Lambda costs can pile up quickly, probably before you can pinpoint what you’re paying for. Plus, traffic can vary greatly from hour to hour, day to day, week to week, and month to month.

It’s also a bad idea to wait until the end of the month to see your Lambda bill because there’s no way to change it by then. Perhaps you experienced some cost spikes that you didn’t notice until the bill arrived, and you can’t figure out why they occurred or how you can prevent them in the future.

This is where CloudZero can help.

With CloudZero, you can capture, analyze, and present your AWS costs per unit for business concepts you actually care about, such as:

  • Cost per customer
  • Cost per feature
  • Cost per product
  • Cost per team
  • Cost per project
  • Cost per environment
Dashboard

With this intelligence at your fingertips, you can pinpoint exactly who, what, and why your AWS costs are changing. The majority of other tools show you total costs and averages — not this level of instantly actionable cost insight.

Also, CloudZero detects cost anomalies in real-time.

Dashboard

CloudZero then alerts individual engineers or your entire FinOps team via Slack or email to the anomalies, so you can stop the bleeding before it wipes out your budget.

With CloudZero, you can also forecast and budget costs, analyze Kubernetes costs, and consolidate costs from AWS, Google Cloud, and Azure in one platform. Our customers, like Drift, have already reduced their annual AWS spending by $2.4 million. You can too.

to see how you can optimize your costs as well.

AWS Lambda Pricing FAQs

The following are answers to frequently asked questions about AWS Lambda pricing.

What is the AWS Lambda pricing model?

You pay per use. If your code isn’t running, there are no charges to you.

How does AWS Lambda billing calculate charges?

AWS Lambda charges you for the serverless compute time you use; the total time it takes your code to execute and the number of requests for your functions.

Several variables determine Lambda costs, including the type of CPU architecture (Arm-based or X86), the number of requests, the time frame (code/function execution duration), the duration of each request (measured in milliseconds), and the amount of memory you allocate it (in GB-seconds).

Is AWS Lambda cheaper than Amazon EC2 for compute usage?

EC2 pricing may appear lower and more straightforward than Lambda pricing on the surface. Depending on your use case, this may vary. The Lambda service eliminates many of the costs associated with provisioning and managing your own servers, as one example.

Also, unlike EC2 instances, AWS Lambda functions terminate as soon as they finish executing a task, instead of incurring charges for idle time.