Overview

AWS Lambda is a serverless, event-driven compute service that allows developers to run code without provisioning or managing servers. Introduced by Amazon Web Services, Lambda automatically manages the computing resources required to run code, scaling capacity up or down as needed in response to incoming events. This approach means developers only pay for the compute time consumed when their functions are actively running, rather than for idle server capacity AWS Lambda pricing model.

Lambda functions are designed to respond to a wide array of event sources, both within and outside the AWS ecosystem. Common triggers include changes in data state in Amazon S3 buckets, updates in Amazon DynamoDB tables, messages from Amazon SQS queues, and HTTP requests via Amazon API Gateway. This event-driven model makes AWS Lambda suitable for building reactive and scalable applications, such as microservices, backend APIs, and real-time data processing pipelines AWS Lambda event sources.

The service abstracts away operational tasks like server maintenance, patching, and capacity planning. Developers upload their code, often packaged as a ZIP file or container image, and configure the triggers. Lambda then handles the execution environment, including runtime management, monitoring, and logging. This focus on code execution rather than infrastructure management aligns with the Function-as-a-Service (FaaS) paradigm, a core component of serverless computing architectures Martin Fowler's definition of serverless.

While offering significant operational benefits, developers new to the AWS ecosystem may encounter a learning curve due to the deep integration with other AWS services. Performance considerations, such as "cold starts" for infrequently invoked functions, can also impact latency, requiring careful architectural design and optimization strategies AWS documentation on cold starts. Despite these considerations, AWS Lambda remains a foundational service for building scalable, cost-effective, and resilient applications in the cloud.

Key features

  • Event-driven execution: Functions run in response to a variety of events, such as HTTP requests, database changes, or file uploads.
  • Automatic scaling: Lambda automatically scales the number of concurrent executions to match the incoming request rate without manual intervention.
  • Integrated monitoring and logging: Provides built-in integration with Amazon CloudWatch for monitoring function performance and logging outputs.
  • Language support: Supports code written in Python, Node.js, Java, C#, Go, Ruby, and Rust, along with custom runtimes for other languages.
  • Container image support: Allows packaging and deploying functions as container images, offering greater control over runtime environments and dependencies.
  • Concurrency controls: Enables developers to manage the maximum number of concurrent executions for a function to prevent resource exhaustion or manage downstream service load.
  • Version management and aliases: Supports deploying multiple versions of a function and using aliases to manage traffic routing between them for canary deployments or A/B testing.
  • VPC connectivity: Functions can access resources within an Amazon Virtual Private Cloud (VPC) for secure access to private databases and services.
  • Provisioned Concurrency: A feature to keep functions initialized and ready to respond in milliseconds, reducing cold start latency for critical applications AWS Provisioned Concurrency.

Pricing

AWS Lambda pricing is based on a pay-as-you-go model, with charges for the number of requests and the total compute duration consumed. The free tier includes a significant allowance.

Metric Free Tier (per month) On-Demand Pricing (after free tier) As of Date
Requests 1 million requests $0.20 per 1 million requests 2026-05-08
Compute Duration 400,000 GB-seconds $0.0000166667 per GB-second 2026-05-08
Provisioned Concurrency N/A Charged for configured GB-seconds and duration, plus standard request charges 2026-05-08

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

Common integrations

  • Amazon API Gateway: For creating RESTful APIs that trigger Lambda functions for backend logic API Gateway Lambda integration.
  • Amazon S3: To process data uploaded to S3 buckets, such as image resizing or log file analysis S3 event notifications.
  • Amazon DynamoDB: For reacting to data modifications in DynamoDB tables, enabling real-time data processing or change data capture DynamoDB Streams with Lambda.
  • Amazon SQS: To process messages asynchronously from message queues, supporting decoupled architectures SQS Lambda integration.
  • Amazon Kinesis: For real-time processing of streaming data, such as log aggregation or IoT data analysis Kinesis Lambda integration.
  • AWS Step Functions: For orchestrating complex workflows involving multiple Lambda functions and other AWS services AWS Step Functions overview.
  • Amazon EventBridge: To build event-driven architectures by routing events from various sources to Lambda functions EventBridge Lambda targets.
  • AWS IoT Core: For building IoT backends that process data from connected devices IoT Core Lambda actions.

Alternatives

  • Google Cloud Functions: Google's serverless compute platform for event-driven applications on Google Cloud.
  • Azure Functions: Microsoft Azure's serverless solution for running small pieces of code in the cloud.
  • Cloudflare Workers: A serverless platform that allows developers to deploy JavaScript, WebAssembly, or other compatible code directly on Cloudflare's global network edge.

Getting started

To get started with AWS Lambda, you typically define a function, specify its runtime, and configure its triggers. The following Python example demonstrates a simple "Hello World" Lambda function that returns a greeting.

import json

def lambda_handler(event, context):
    # TODO implement
    name = "World"
    if 'queryStringParameters' in event and 'name' in event['queryStringParameters']:
        name = event['queryStringParameters']['name']
    elif 'name' in event:
        name = event['name']

    response_body = {
        "message": f"Hello, {name}!",
        "input": event
    }

    return {
        'statusCode': 200,
        'headers': {
            'Content-Type': 'application/json'
        },
        'body': json.dumps(response_body)
    }

This lambda_handler function is the entry point for your Lambda code. It takes two arguments:

  • event: A Python dictionary containing data from the trigger that invoked the function.
  • context: An object providing runtime information about the invocation, function, and execution environment Lambda context object.

To deploy this function:

  1. Save the code: Save the code above as lambda_function.py.
  2. Create a deployment package: For simple functions, this file can be zipped directly. For functions with external dependencies, these dependencies must be included in the ZIP file.
  3. Create a Lambda function: Use the AWS Management Console, AWS CLI, or AWS SDKs to create a new Lambda function.
  4. Configure runtime: Select Python 3.x as the runtime and specify lambda_function.lambda_handler as the handler.
  5. Upload code: Upload your ZIP file containing lambda_function.py.
  6. Configure a trigger: For example, set up an API Gateway trigger to invoke the function via an HTTP endpoint Lambda API Gateway trigger.

Once deployed and triggered, the function will execute, and the response will be returned via API Gateway or logged to Amazon CloudWatch.