Overview

AWS Lambda is a serverless, event-driven compute service that enables developers to run code for virtually any type of application or backend service without provisioning or managing servers. It automatically manages the underlying compute infrastructure, including server and operating system maintenance, capacity provisioning, and automatic scaling. Developers upload their code, and Lambda handles the execution, scaling it up or down based on the incoming event volume. This model allows developers to focus on writing code rather than managing infrastructure.

Lambda functions are stateless, meaning they do not retain in-memory state from previous invocations. This design promotes scalability and resilience, as any instance of a function can handle any request. Functions can be triggered by over 200 AWS services and SaaS applications, responding to events such as changes in data in an Amazon S3 bucket, updates in an Amazon DynamoDB table, or HTTP requests from an Amazon API Gateway endpoint. This event-driven paradigm makes Lambda particularly well-suited for building microservices, backend APIs, data processing pipelines, and automating infrastructure tasks.

The service supports code written in various programming languages, including Python, Node.js, Java, Go, C# (.NET), and Ruby, and also allows for custom runtimes. This flexibility enables teams to use their preferred languages and tools. For more complex deployments, Lambda also supports packaging functions as container images, offering greater control over the application environment and dependencies. The AWS Lambda documentation provides detailed guides on function development and deployment.

AWS Lambda is designed for high availability and fault tolerance, automatically distributing functions across multiple availability zones within an AWS region. Its pay-per-use pricing model, based on the number of requests and the compute duration, aligns costs directly with usage, making it efficient for workloads with variable traffic patterns. While initial setup and understanding of the AWS ecosystem can present a learning curve for new users, the extensive documentation and a large community support its adoption. The serverless model, as described by Mozilla's Developer Network Glossary on serverless computing, abstracts server management, allowing developers to concentrate on application logic.

Key features

  • Event-Driven Execution: Automatically runs code in response to events from over 200 AWS services and SaaS applications, enabling highly responsive and scalable architectures.
  • Automatic Scaling: Scales function execution capacity up and down automatically based on demand, eliminating the need for manual capacity planning.
  • Integrated Security: Integrates with AWS Identity and Access Management (IAM) to control access to functions and other AWS resources, and supports Virtual Private Cloud (VPC) for network isolation.
  • Multiple Language Runtimes: Supports native runtimes for Python, Node.js, Java, Go, C# (.NET), and Ruby, along with the ability to create custom runtimes for other languages.
  • Container Image Support: Allows packaging and deploying Lambda functions as container images, providing flexibility for dependencies and build processes.
  • Provisioned Concurrency: Offers the ability to keep functions initialized and hyper-ready to respond in milliseconds, reducing cold start latencies for critical applications.
  • Asynchronous and Synchronous Invocation: Supports both synchronous invocations for immediate responses (e.g., API requests) and asynchronous invocations for background processing (e.g., data pipeline steps).
  • Monitoring and Logging: Integrates with Amazon CloudWatch for monitoring function performance and logging outputs, providing operational visibility.

Pricing

AWS Lambda's pricing model is pay-per-use, based on the number of requests and the compute time consumed. There is a free tier available that includes 1 million free requests and 400,000 GB-seconds of compute time per month. Costs are incurred only when these free tier limits are exceeded.

Metric Pricing (as of 2026-05-08)
Requests $0.20 per 1 million requests after free tier
Compute Duration Calculated per GB-second, varies by memory allocation. Example: $0.0000166667 for every GB-second after free tier
Data Transfer Out Standard AWS data transfer rates apply. First 100 GB per month free.

For detailed and up-to-date pricing information, refer to the AWS Lambda pricing page.

Common integrations

  • Amazon API Gateway: Used to create RESTful APIs or WebSocket APIs that trigger Lambda functions for backend logic. Learn more about integrating API Gateway with Lambda.
  • Amazon S3: Triggers Lambda functions in response to object creation, deletion, or modification events in S3 buckets, commonly used for data processing. Refer to S3 event notifications with Lambda.
  • Amazon DynamoDB: Invokes Lambda functions when items in a DynamoDB table are created, updated, or deleted, enabling real-time data processing. See DynamoDB Streams and Lambda.
  • Amazon SQS: Processes messages from SQS queues, allowing for asynchronous, decoupled application components. Details on Lambda as an SQS consumer.
  • Amazon Kinesis: Processes real-time streaming data from Kinesis data streams with Lambda functions for analytics or transformations. Information available on Kinesis and Lambda integration.
  • Amazon CloudWatch: Monitors Lambda function performance, logs invocations, and triggers functions based on scheduled events or alarms. Explore monitoring Lambda with CloudWatch.
  • AWS Step Functions: Orchestrates multiple Lambda functions and other AWS services into serverless workflows. Learn about Step Functions and Lambda.

Alternatives

  • Azure Functions: Microsoft's serverless compute service, offering similar event-driven execution and language support within the Azure ecosystem.
  • Cloudflare Workers: A serverless platform that allows developers to deploy JavaScript, Rust, C, or C++ code that runs on Cloudflare's global network edge.
  • Google Cloud Functions: Google's serverless platform for building event-driven applications, supporting various languages and deep integration with Google Cloud services.
  • Vercel Edge Functions: Serverless functions deployed globally on Vercel's Edge Network, primarily used for web applications built with frameworks like Next.js.

Getting started

Below is a basic example of an AWS Lambda function written in Python that returns a simple "Hello from Lambda!" message. This function can be invoked via an API Gateway endpoint or other AWS services.


import json

def lambda_handler(event, context):
    # TODO implement
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

To deploy this function:

  1. Save the code: Save the Python code above in a file named lambda_function.py.
  2. Create a deployment package: For simple functions like this, the .py file itself is often sufficient. For functions with external dependencies, you would package them into a .zip file.
  3. Create a Lambda function in the AWS Console:
    • Navigate to the AWS Lambda console.
    • Choose "Create function".
    • Select "Author from scratch".
    • Provide a Function name (e.g., MyHelloFunction).
    • Choose "Python 3.9" as the Runtime.
    • For Execution role, select "Create a new role with basic Lambda permissions".
    • Click "Create function".
  4. Upload your code:
    • Once the function is created, scroll down to the "Code source" section.
    • Upload your lambda_function.py file directly or upload a .zip file if you have dependencies.
    • Ensure the Handler is set to lambda_function.lambda_handler (filename.function_name).
  5. Test the function:
    • In the Lambda console, click the "Test" tab.
    • Configure a test event (e.g., use the "hello-world" template).
    • Click "Invoke" to run your function and see the output.

This provides a basic setup. For more advanced configurations, such as integrating with an API Gateway or other services, refer to the AWS Lambda getting started guide.