Overview
AWS Lambda is a core serverless computing service offered by Amazon Web Services, designed to execute code in response to events without requiring developers to provision or manage servers. Introduced in 2014, Lambda represents a shift in cloud computing paradigms, moving from traditional server management to an event-driven, function-as-a-service (FaaS) model. Developers upload their code, and Lambda handles all the underlying infrastructure, including server maintenance, capacity provisioning, automatic scaling, and code monitoring.
The service is particularly well-suited for building event-driven microservices, automating backend tasks, and processing data streams. For instance, Lambda functions can be triggered by changes in data in an Amazon S3 bucket, messages arriving in an Amazon SQS queue, or HTTP requests via Amazon API Gateway. This enables the creation of highly decoupled and scalable applications where components react independently to specific events.
AWS Lambda supports a wide array of programming languages, including Python, Node.js, Java, Go, C#, Ruby, and PowerShell, either directly through managed runtimes or via custom runtimes for other languages. It also supports deploying functions as container images, offering greater flexibility in packaging dependencies and custom runtimes. This broad language support, combined with deep integration across the vast AWS ecosystem, positions Lambda as a versatile tool for various use cases, from simple data transformations to complex backend logic for web and mobile applications.
While Lambda offers significant operational benefits by abstracting server management, developers need to consider factors such as cold start times, which can impact latency for infrequently invoked functions, and the complexities of managing serverless applications across multiple integrated AWS services. Tools like AWS X-Ray assist in monitoring and debugging these distributed architectures. The service adheres to a pay-per-use model, charging based on the number of requests and the duration of code execution, measured in gigabyte-seconds, which can lead to cost efficiencies for intermittent or highly variable workloads.
Key features
- Event-driven execution: Functions are automatically triggered by various AWS services and custom events, such as data uploads to S3, database modifications, or API Gateway requests (AWS Lambda Invocation models).
- Automatic scaling: Lambda automatically scales resources to match the incoming request rate, from a few requests per day to thousands per second, without manual configuration (AWS Lambda Scaling documentation).
- Serverless operations: Eliminates the need to provision, manage, or maintain servers, allowing developers to focus solely on code.
- Language and runtime support: Supports multiple managed runtimes (Python, Node.js, Java, Go, C#, Ruby, PowerShell) and allows for custom runtimes or deployment via container images (AWS Lambda Runtimes).
- Integrated with AWS ecosystem: Natively integrates with over 200 AWS services, including Amazon S3, DynamoDB, API Gateway, SQS, Kinesis, and CloudWatch.
- Pay-per-use billing: Charges are based on the number of requests and the compute duration consumed, measured in gigabyte-seconds, with a free tier included (AWS Lambda Pricing).
- High availability and fault tolerance: Functions are inherently highly available and fault-tolerant, running across multiple Availability Zones within an AWS Region.
- Container image support: Allows packaging and deploying Lambda functions as container images up to 10 GB in size, enabling the use of preferred container tooling (AWS Blog on Container Image Support).
Pricing
AWS Lambda offers a pay-as-you-go pricing model with a free tier. Costs are primarily determined by the number of requests, the duration of code execution, and the memory allocated to the function. Data transfer out from AWS Lambda is also charged.
Pricing effective as of June 22, 2026. For detailed and up-to-date pricing, refer to the official AWS Lambda pricing page.
| Component | Free Tier (per month) | On-Demand Pricing (after free tier) |
|---|---|---|
| Requests | 1 million requests | $0.20 per 1 million requests |
| Compute Duration | 400,000 GB-seconds | $0.0000166667 per GB-second |
| Container Image Storage | N/A | $0.05 per GB-month (for ECR storage) |
| Ephemeral Storage (for /tmp) | N/A | Included up to 512 MB, additional charges for more |
| Data Transfer Out | Included with AWS Free Tier | Varies by region and destination; typically $0.09 per GB to the internet |
Common integrations
- Amazon API Gateway: For building HTTP APIs that trigger Lambda functions as backend services (AWS Lambda API Gateway integration).
- Amazon S3: For processing data uploaded or modified in S3 buckets, such as image resizing or data ingestion (AWS Lambda S3 integration).
- Amazon DynamoDB: For reacting to changes in DynamoDB tables via DynamoDB Streams, enabling real-time data processing (AWS Lambda DynamoDB integration).
- Amazon SQS (Simple Queue Service): For processing messages from message queues, enabling asynchronous communication between services (AWS Lambda SQS integration).
- Amazon Kinesis: For processing real-time streaming data, such as log processing or real-time analytics (AWS Lambda Kinesis integration).
- Amazon CloudWatch: For monitoring Lambda function performance, logs, and setting up alarms based on metrics (AWS Lambda CloudWatch monitoring).
- AWS Step Functions: For orchestrating complex workflows that involve multiple Lambda functions and other AWS services (AWS Lambda Step Functions integration).
- Amazon EventBridge: For building event-driven architectures that react to events from AWS services, custom applications, and SaaS applications (Amazon EventBridge Overview).
Alternatives
- Google Cloud Functions: Google's serverless compute platform for building event-driven microservices on Google Cloud.
- Azure Functions: Microsoft Azure's serverless compute service that enables running event-driven code with a range of language and hosting options.
- Cloudflare Workers: A serverless platform that runs JavaScript, WebAssembly, or other languages at the edge, closer to users, for high-performance applications.
- Fly.io: Offers a platform to run full-stack apps and databases closer to users, providing alternatives for edge compute needs that might use Lambda for specific functions.
- Render: A unified cloud platform to build and run all your apps and websites with a focus on ease of use, offering services like Web Services that can host similar backend logic.
Getting started
This example demonstrates a basic Python Lambda function that returns a "Hello from Lambda!" message. This function can be deployed and triggered, for instance, via an API Gateway endpoint or manually for testing.
import json
def lambda_handler(event, context):
# TODO implement
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
To deploy this function:
- Save the code: Save the code above as
lambda_function.py. - Create a deployment package: For this simple example, the
lambda_function.pyfile itself serves as the deployment package. For functions with external dependencies, you would create a ZIP file containing your code and dependencies. - Create a Lambda function: Navigate to the AWS Lambda console (AWS Lambda homepage). Click "Create function".
- Configure the function:
- Select "Author from scratch".
- Provide a Function name (e.g.,
MyHelloWorldFunction). - Choose "Python 3.9" (or your preferred Python version) as the Runtime.
- For Architecture, select "x86_64".
- Under "Change default execution role", select "Create a new role with basic Lambda permissions". This creates an IAM role with permissions to write logs to CloudWatch.
- Click "Create function".
- Upload your code: In the Function code section of your newly created function, you can directly paste the code into the inline editor, or upload your
.zipfile if you have external dependencies. - Test the function: Click the "Test" tab. Configure a test event (e.g., use the "hello-world" template, then click "Save" and "Test"). The execution results will show the output returned by your function.