AWS Lambda
Cloud service · AWS · Updated

AWS Lambda

In short

AWS Lambda is a serverless computing service provided by Amazon Web Services that allows developers to run code in response to events without provisioning or managing servers.

Cloud Services Hub →

Free AWS Lambda tools

7 key features of AWS Lambda

AWS Lambda provides automatic scaling, serverless execution, subsecond metering, built-in fault tolerance, event-driven architecture, and support for multiple programming languages, enabling efficient and cost-effective application development and deployment.

01
Automatic Scaling

AWS Lambda automatically scales your application by running code in response to each event. The number of events processed can scale precisely with the size of the workload, from a few requests per day to thousands per second.

02
No Servers to Manage

Lambda removes the need for server management. It takes care of everything required to run and scale your code with high availability, from server and operating system maintenance, to capacity provisioning and automatic scaling.

03
Subsecond Metering

Lambda Event Functions are priced per request and execution duration, Lambda MicroVMs per instance-second, and Lambda Web Functions per request and active CPU time.

04
Built-in Fault Tolerance

Lambda has built-in fault tolerance. It maintains compute capacity and redundancy across multiple Availability Zones (AZs) in a region to ensure the continuous processing of your applications.

05
Event-Driven

Lambda makes it easy to execute code in response to events from AWS services like S3, DynamoDB, Kinesis, SNS, and more. This enables you to build applications that react quickly to new information.

06
Support for Multiple Programming Languages

AWS Lambda supports multiple programming languages, including Node.js, Python, Java, Go, Ruby, and C#, allowing you to use a language that you are comfortable with or one that is best suited to your application.

07
Execution Roles and Resource Policies

Lambda permissions control security and access through execution roles governing interactions with AWS services and resource policies governing access to function code.

Where AWS Lambda is used

AWS Lambda use cases span real-time file processing, serverless APIs, data transformation, stream processing, automated tasks, and IoT backend services, showcasing its versatility and efficiency in handling a wide range of serverless computing tasks.

  1. 01
    Real-time File Processing

    AWS Lambda can be used for real-time file processing. Whenever new files are uploaded to AWS S3, Lambda can automatically trigger and process these files, such as image resizing, video transcoding, or any custom file manipulation required by the application.

  2. 02
    Serverless APIs

    Building serverless APIs with AWS Lambda and Amazon API Gateway enables developers to create scalable and cost-efficient RESTful services. Lambda functions can execute the business logic in response to HTTP requests made via API Gateway, eliminating the need to manage server infrastructure.

  3. 03
    Data Transformation and ETL

    AWS Lambda facilitates data transformation and ETL (Extract, Transform, Load) tasks. It can be used to clean, process, and aggregate data in real-time as it moves between databases, streams, or storage layers, making it ideal for building complex data processing workflows.

  4. 04
    Real-time Stream Processing

    Lambda functions can be used for real-time processing of streaming data from Amazon Kinesis or DynamoDB Streams. This allows for immediate analysis and data enrichment, enabling applications to react swiftly to new information.

  5. 05
    Automated Backups and Everyday Tasks

    Automating backups, snapshots, and daily tasks is another practical use case for AWS Lambda. By scheduling Lambda functions, tasks like database backups, cleanup jobs, and report generation can be executed regularly without manual intervention.

  6. 06
    IoT Backend

    AWS Lambda serves as a highly scalable backend for Internet of Things (IoT) applications. It can process and respond to messages from a multitude of devices, ensuring efficient communication and operational management in IoT ecosystems.

How AWS Lambda is priced

AWS Lambda pricing is based on the number of requests and the compute duration in GB-s, with costs calculated per 1 million requests and based on the allocated memory and execution time.

Requests

AWS Lambda charges a fee for every 1 million requests made to your functions.

Compute Duration

For on-demand Lambda Event Functions, compute duration is charged in gigabyte-seconds (GB-s), based on allocated memory, and rounded up to the nearest 1 ms.

Lambda Managed Instances

Charges comprise $0.20 per million requests, standard EC2 instance charges, and a management fee of 15% of the EC2 on-demand instance price. Per-request execution duration is not billed separately, and eligible EC2 pricing options can reduce instance costs.

Lambda Web Functions

Charges cover requests, active CPU time, and memory. CPU time spent waiting on I/O is not billed, and concurrent requests share execution-environment compute costs.

Durable Functions

In addition to existing compute charges, including replay sub-invocations, durable functions charge for durable operations, data written in GB, and retained data in prorated GB-months. On-demand functions incur no duration charges while suspended in a wait operation.

Tenant Isolation

A charge applies whenever Lambda creates a new tenant-isolated execution environment to serve a request, based on allocated memory and CPU architecture.

Ephemeral Storage

The first 512 MB of configured ephemeral storage is free. Additional configured storage is charged based on its amount and function execution duration.

Provisioned Concurrency

Charges depend on configured concurrency, allocated memory, and how long Provisioned Concurrency remains enabled, rounded up to five-minute intervals. Requests and execution duration are charged separately, and the Lambda free tier does not apply to functions using Provisioned Concurrency.

SnapStart

Snapshot caching is charged for at least three hours and per millisecond thereafter while the function version is active. Restoring an execution environment incurs a separate charge; both charges depend on allocated memory. These SnapStart charges do not apply to supported Java managed runtimes.

HTTP Response Streaming

Event Functions using HTTP response streaming are charged per GB written to the response stream, with the first 6 MB per request streamed at no cost.

Provisioned Event Pollers

Standard Event Poller Unit (EPU) charges apply to event source mappings that use provisioned pollers with sources such as Kafka or SQS.

Lambda MicroVM Compute and Snapshots

Compute is billed per second based on baseline and peak usage, with additional charges for snapshot operations and storage. Baseline charges apply while a MicroVM runs, and consumption above the baseline is billed by active usage.

Lambda MicroVM Data Transfer

Lambda MicroVM usage also incurs data transfer charges.

Services AWS Lambda works with

Amazon S3Amazon S3

AWS Lambda can be triggered by S3 events, such as file uploads or deletions, allowing you to process data, generate thumbnails, or transform files in real-time.

Amazon DynamoDBAmazon DynamoDB

Lambda can respond to changes in DynamoDB tables, such as item modifications, enabling real-time data processing, notifications, or synchronization with other services.

Amazon API GatewayAmazon API Gateway

API Gateway allows you to create and manage RESTful APIs that trigger Lambda functions. This integration is often used to build serverless web applications and microservices.

Amazon CloudWatchAmazon CloudWatch

Lambda integrates with CloudWatch for logging, monitoring, and alerting. You can use CloudWatch Events to trigger Lambda functions based on schedule or system events.

AWS Step FunctionsAWS Step Functions

Lambda works with Step Functions to build complex workflows and state machines, enabling orchestration of multiple Lambda functions and other AWS services.

Amazon KinesisAmazon Kinesis

Lambda can process streaming data in real-time from Kinesis streams and Firehose, allowing for applications such as log processing, real-time analytics, and event-driven ETL.

Amazon AppFlowAmazon AppFlow

Lambda functions implement custom connectors for AppFlow, handling operations such as authentication, schema discovery, and data retrieval for applications without a built-in connector.

Amazon AthenaAmazon Athena

Lambda functions power Athena federated query connectors, allowing SQL queries to read data outside Amazon S3. Lambda also executes Athena user-defined functions for custom processing within queries.

What is AWS Lambda

4 min read

AWS Lambda is a pivotal service within the Amazon Web Services (AWS) ecosystem, offering a serverless compute service that allows developers to run code in response to events without provisioning or managing servers. This groundbreaking service, introduced by AWS, revolutionized the way applications are built and deployed, enabling developers to focus purely on their code while Lambda takes care of the underlying infrastructure management. 

Existing Lambda functions are now called Lambda Event Functions; no code changes or redeployment are required.

Requests to the Lambda API must be authenticated with a signature; Lambda supports AWS Signature Version 4.

Lambda durable functions support multi-step workflows that suspend and resume across multiple invocations using timers, callbacks, and polling conditions. Asynchronous durable executions can last up to one year.

Lambda MicroVMs provide isolated environments with customer-controlled lifecycles for workloads such as user-generated or AI-generated code. Each runs Amazon Linux 2023 from an image you provide; you can run, suspend, resume, and terminate it through the API. Suspension preserves memory and disk state, and the total lifespan, including suspended time, is limited to eight hours.

Event Functions also offer tenant isolation mode: each underlying execution environment is associated with a particular tenant and never processes requests from other tenants invoking the same function.

As a cornerstone of serverless architectures, Lambda supports a variety of programming languages, including Node.js, Python, Java, Go, Ruby, and C#, making it a versatile option for developers with different skill sets. One of the most striking features of Lambda is its event-driven nature. Lambda functions can be triggered by various AWS services or custom events, making it an ideal tool for executing code in response to HTTP requests via Amazon API Gateway, processing stream records in Amazon DynamoDB, changing data in S3 buckets, or updating messages in Amazon SNS or Amazon SQS. This flexibility allows developers to architect applications that are both scalable and resilient without needing to manage the scaling policy explicitly. 

Lambda Web Functions run Node.js HTTP servers directly, using frameworks such as Express, Hono, or React Router without adapters. Each execution environment handles multiple concurrent requests, and Lambda supplies an HTTPS endpoint, scales to zero when idle, and supports deployment across multiple Regions behind one endpoint.

New AWS accounts start with reduced concurrency and memory quotas for Lambda Functions and MicroVMs, and reduced vCPU and request-rate quotas for Web Functions. AWS raises these quotas automatically based on usage.

Lambda Managed Instances run Event Functions on fully managed EC2 instances in your VPC. You can select instance types and process multiple requests concurrently in one execution environment, while Lambda manages provisioning, scaling, patching, and instance lifecycle.

The usual single-invocation timeout is 15 minutes. Lambda Managed Instances support up to 90 minutes for asynchronous invocations and event source mappings other than Amazon MQ and Amazon DocumentDB.

Managed Instances have quotas separate from default Lambda quotas and are also subject to account-level EC2 quotas, including instance-type vCPU limits, EBS volume limits, and available IP addresses in VPC subnets.

Provisioned Concurrency keeps Event Functions initialized and ready to respond in double-digit milliseconds, providing greater control over latency-sensitive workloads.

SnapStart reduces startup latency by snapshotting a function's initialized memory and disk state and restoring execution environments from that snapshot instead of initializing them from scratch.

On-demand Lambda Event Functions are charged by request count and execution duration; other Lambda compute options have different billing models. This pricing model allows businesses to reduce costs significantly compared to running dedicated servers or EC2 instances that might not be utilized fully. The cost-effectiveness combined with the ability to scale automatically from a few requests per day to thousands per second makes Lambda a compelling option for startups and large enterprises alike. 

Another significant advantage of Lambda is the integration with other AWS services. This seamless integration allows for the creation of sophisticated serverless architectures that harness the strengths of services like Amazon S3 for storage, Amazon DynamoDB for databases, and Amazon API Gateway for creating RESTful APIs, amongst others.

Moreover, AWS Lambda ensures high availability by maintaining compute capacity across multiple Availability Zones in each region, providing built-in fault tolerance to the applications. For developers seeking to build microservices or simply offload certain tasks from their main application, AWS Lambda offers an efficient, scalable, and cost-effective route.

It's particularly beneficial for handling unpredictable workloads, processing real-time data, and automating cloud workflows without the heavy lifting of server management. As serverless architectures continue to evolve, AWS Lambda is poised to remain at the forefront, offering developers the tools to build more robust, scalable, and efficient applications.

Concepts related to AWS Lambda

AWS Lambda exam questions

Real practice exam questions on AWS Lambda, with the correct answer and its explanation. Answer them with every option in the exam simulator.

AIB-C01

A workplace training company uses an AWS Lambda function to assemble practice quizzes. The function randomly selects 10 different questions from an approved question bank and shuffles their order. Every selected question must remain unchanged, and different attempts are allowed to contain different questions. A business sponsor proposes replacing the function with AI because submitting the same course identifier twice can produce different quizzes. Which recommendation best meets the requirements with the least unnecessary complexity?

Show answerCORRECT ANSWER

Retain the existing function because conventional software can use random selection without requiring a learned model.

The requirements call for sampling approved content, not interpreting information or learning patterns. Random selection can produce different results because the random state changes, even when the course identifier stays the same. This does not make AI necessary or indicate that the existing approach is unsuitable.

MLA-C02

A retailer uses an Amazon Bedrock agent with a function-based action group backed by an AWS Lambda function. The action group contains get_order_status and issue_refund. The Lambda function independently validates customer authorization and refund limits. During testing, the agent sometimes selects issue_refund when a customer only asks about refund eligibility.

The retailer requires the agent to obtain explicit user confirmation for each proposed refund before invoking the Lambda function for issue_refund. Order-status lookups must continue without confirmation. The team wants to retain managed agent orchestration and avoid implementing a custom approval workflow.

Which configuration best meets these requirements?

Show answerCORRECT ANSWER

Set requireConfirmation to ENABLED for issue_refund in the action group's function schema, and leave confirmation disabled for get_order_status.

Function-level confirmation requires the agent to request user confirmation before invoking the selected operation. Enabling it only for issue_refund provides the required approval step without interrupting order-status lookups or replacing managed orchestration.

SAP-C03

A company runs licensed simulation workers as an Amazon ECS service. When a worker becomes unhealthy, ECS replaces its task. An existing coordinator confirms that the failed worker can no longer run and asynchronously invokes an AWS Lambda function to return the worker's reserved license seats to an available-seat counter in Amazon DynamoDB.

Each simulation attempt has a globally unique attempt ID and a DynamoDB reservation item containing the reserved seat count and a status of RESERVED or RELEASED. The available-seat counter is stored in a separate item. Replacement attempts receive new attempt IDs and separate reservations. Reservation items are retained longer than the maximum event replay period.

The same failed-attempt event can invoke the function concurrently more than once. The function can also time out after a DynamoDB request succeeds but before it receives the response. Every confirmed failed attempt must eventually return its seats, but no attempt may increase the available-seat counter more than once. Recovery must remain automatic after transient failures.

Which implementation meets these requirements?

Show answerCORRECT ANSWER

Use TransactWriteItems to conditionally change the reservation from RESERVED to RELEASED and increment the available-seat counter by the reserved count in the same transaction. Retry transient failures. If the condition fails, verify that the reservation is already RELEASED and treat that result as successful completion.

The transaction commits both changes or neither change. The condition on the stable attempt-specific reservation allows only one transaction to return the seats. Concurrent invocations and retries after an ambiguous response cannot increment the counter again. Transient failures can be retried without leaving a partially completed release, and separate replacement attempts retain independent reservations.

Practice AWS Lambda in a full exam

Questions on AWS Lambda in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

Learn AWS Lambda in lessons

33 short lessons on AWS Lambda in 11 certification courses.

and 27 more lessons

Open the lessons

AWS architecture icons are the property of Amazon Web Services. BlowStack is not affiliated with or endorsed by AWS.