CLOUD SERVICE · AWS

AWS Lambda

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 →
Arch_AWS Lambda_64 imageIcon source: AWS

Free AWS Lambda tools

What is AWS Lambda

Read the extensive description

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.

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.

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.

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

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.

Key AWS Lambda Features

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.

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.

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.

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.

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.

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.

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.

AWS Lambda Use Cases

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.

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.

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.

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.

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.

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.

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.

AWS Lambda pricing models

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.

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.

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.

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.

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.

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 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.

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.

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.

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.

Requests

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

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.

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.

Services AWS Lambda integrates with

Amazon Kinesis image Amazon 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.

Open Amazon Kinesis →
Amazon Simple Notification Service image Amazon Simple Notification Service (Amazon SNS)

Lambda can be invoked by SNS to process messages or notifications, enabling event-driven workflows and real-time processing.

Open Amazon Simple Notification Service (Amazon SNS) →
Amazon Simple Queue Service image Amazon Simple Queue Service (Amazon SQS)

Lambda can process messages from SQS queues, allowing you to build scalable and reliable background job processing.

Open Amazon Simple Queue Service (Amazon SQS) →
AWS Step Functions image AWS Step Functions

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

Open AWS Step Functions →
Amazon DynamoDB image Amazon DynamoDB

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

Open Amazon DynamoDB →
Amazon API Gateway image Amazon 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.

Open Amazon API Gateway →
Amazon CloudWatch image Amazon 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.

Open Amazon CloudWatch →
Amazon Simple Storage Service image Amazon 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.

Open Amazon S3 →

Concepts related to AWS Lambda