Back to category
Cloud

What Is AWS Lambda?

Learn what AWS Lambda is, how Lambda functions work, common use cases, triggers, concurrency, cold starts, pricing concepts, and when to use serverless functions.

What Is AWS Lambda?

AWS Lambda is a serverless compute service that runs application code without requiring you to provision or manage servers.

You deploy a function, define what should trigger it, and AWS provides the underlying compute capacity needed to execute the code. Lambda handles infrastructure tasks such as server maintenance, capacity provisioning, and automatic scaling.

Lambda is commonly used for APIs, event processing, file processing, background jobs, automation, and applications built around event-driven architectures.

AWS Lambda at a Glance

ConceptWhat it means
Lambda functionThe code Lambda executes
HandlerEntry point into your function
TriggerEvent that invokes the function
InvocationOne execution of the function
Execution environmentRuntime environment where your code runs
ConcurrencyNumber of invocations running simultaneously
Cold startInitialization required for a new execution environment
TimeoutMaximum time an invocation can execute
LayerReusable code or dependencies attached to functions
VersionImmutable snapshot of a Lambda function

How Does AWS Lambda Work?

A typical Lambda workflow looks like this:

Event → AWS Lambda → Create or reuse execution environment → Run function handler → Call database/API/service → Return result

An event can come from many sources.

For example:

HTTP request → API Gateway → Lambda → DynamoDB

Or:

File uploaded → Amazon S3 → Lambda → Process image

Or:

Message → SQS → Lambda → Process job

When Lambda receives an invocation, it either uses an existing execution environment or prepares a new one.

Preparing a new environment includes downloading the function code, starting the runtime, and running initialization code outside the handler. This initialization contributes to what is commonly called a cold start.

What Is a Lambda Function?

A Lambda function is the code you deploy to AWS Lambda.

For example, a Python function might look like:

def lambda_handler(event, context):
    name = event.get("name", "world")

    return {
        "statusCode": 200,
        "body": f"Hello {name}"
    }

AWS invokes the handler whenever the configured trigger sends an event.

Lambda supports multiple programming languages and also allows functions to be packaged using container images.

What Can Trigger AWS Lambda?

Lambda is built around events.

Common triggers include:

  • Amazon API Gateway
  • Amazon S3
  • Amazon SQS
  • Amazon SNS
  • Amazon EventBridge
  • DynamoDB Streams
  • Kinesis
  • Application Load Balancer
  • scheduled events
  • direct application invocations

This makes Lambda particularly useful for event-driven applications.

Common AWS Lambda Use Cases

API backends

Lambda can execute backend logic behind API Gateway or another HTTP entry point.

Example:

User → API Gateway → Lambda → Database

This works well for APIs with variable or intermittent traffic because infrastructure does not need to remain continuously provisioned.

File processing

S3 events can invoke Lambda whenever an object is created.

Typical tasks include:

  • resizing images
  • parsing CSV files
  • generating thumbnails
  • validating uploads
  • processing documents

Queue processing

Lambda can consume messages from services such as SQS.

Application → SQS → Lambda → Database

Queues help decouple the producer from the function performing the work.

Scheduled jobs

EventBridge can invoke Lambda on a schedule.

Examples include:

  • cleanup jobs
  • report generation
  • database maintenance
  • synchronization jobs
  • periodic automation

Event-driven automation

Lambda can react to infrastructure and application events without requiring a continuously running service.

How AWS Lambda Scales

Lambda increases the number of execution environments as requests increase.

A useful approximation for required concurrency is:

Concurrency ≈ requests per second × average duration

Suppose an application receives:

200 requests per second

and each request runs for:

0.5 seconds

Approximate concurrency is:

200 × 0.5 = 100

AWS currently documents a default regional concurrency quota of 1,000 concurrent executions for standard Lambda accounts, although account-specific limits can differ and quota increases can be requested.

For a deeper explanation, see AWS Lambda Concurrency in the Middleware Knowledge Center.

What Is an AWS Lambda Cold Start?

A cold start occurs when Lambda needs to prepare a new execution environment before executing a request.

Initialization may include:

  1. Preparing the environment
  2. Downloading function code
  3. Starting the runtime
  4. Loading dependencies
  5. Executing initialization code
  6. Invoking the handler

If Lambda can reuse an existing environment, much of that initialization work is avoided.

Cold starts therefore affect startup latency rather than the normal application logic alone.

See AWS Lambda Cold Starts for a deeper explanation.

AWS Lambda Timeout

For standard Lambda compute, the configurable timeout ranges from 1 second to 900 seconds, or 15 minutes.

The default timeout is 3 seconds.

AWS now also offers Lambda Managed Instances. Certain asynchronous and event-source-mapping invocations running on Managed Instances can use timeouts of up to 5,400 seconds, or 90 minutes. Synchronous invocations and some event sources remain limited to 15 minutes.

This distinction matters when discussing modern Lambda execution limits.

AWS Lambda Concurrency

Concurrency is the number of function requests executing at the same time.

If 50 requests are currently running:

Concurrency = 50

Lambda provides two major controls for standard function concurrency:

Reserved concurrency isolates capacity for a function while also placing an upper limit on its concurrency.

Provisioned concurrency creates initialized execution environments in advance, primarily to reduce cold-start latency.

These solve different problems and should not be treated as interchangeable.

AWS Lambda vs. Traditional Servers

AWS LambdaTraditional server
Event-drivenUsually continuously running
Infrastructure managed by AWSInfrastructure managed by you or your platform
Automatic function scalingScaling must be configured
Pay around execution/resource usePay for provisioned infrastructure
Execution limits applyGreater workload flexibility
Ideal for short/event-driven workBetter for some long-running workloads

Lambda is not automatically better than running an application on containers or VMs.

The right choice depends on:

  • workload duration
  • traffic patterns
  • startup sensitivity
  • resource requirements
  • networking requirements
  • operational model
  • architecture

What Should You Monitor in AWS Lambda?

Useful Lambda signals include:

  • invocations
  • errors
  • duration
  • throttles
  • concurrent executions
  • cold starts
  • memory utilization
  • initialization duration
  • downstream latency

Monitoring these signals together is more useful than viewing them independently.

For example:

Database latency ↑ → Lambda duration ↑ → Concurrency ↑ → Throttling ↑

Throttling appears to be the final problem, but the original cause is the slow database.

This is why Lambda monitoring becomes more useful when metrics, logs, and traces are correlated.

AWS Lambda and OpenTelemetry

OpenTelemetry provides instrumentation and semantic conventions for Function-as-a-Service environments, including AWS Lambda.

The OpenTelemetry community also maintains Lambda instrumentation and Collector layers for sending telemetry to compatible observability backends.

For Lambda, OpenTelemetry spans can contain context such as:

  • function name
  • invocation ID
  • cloud account
  • region
  • function version
  • invoked ARN

This makes it possible to follow serverless requests as they move through distributed applications.

AWS Lambda FAQs

Is AWS Lambda serverless?

Yes. Lambda is a serverless compute service. AWS manages the underlying infrastructure while developers deploy and configure functions.

Does AWS Lambda run continuously?

Standard Lambda functions run in response to invocations rather than behaving like permanently running application servers.

What is an AWS Lambda function?

A Lambda function is a unit of application code deployed to AWS Lambda and executed when an event invokes it.

What is the AWS Lambda timeout?

Standard Lambda functions can be configured for up to 900 seconds. Certain asynchronous workloads running on Lambda Managed Instances can now use longer timeouts, up to 90 minutes.

What is Lambda concurrency?

Lambda concurrency is the number of function invocations being processed simultaneously.

What causes a Lambda cold start?

A cold start occurs when Lambda needs to prepare a new execution environment instead of reusing an existing one.

Is Lambda good for APIs?

Yes. Lambda is commonly used behind services such as API Gateway for APIs with event-driven or variable workloads.

How do you monitor AWS Lambda?

Monitor invocation volume, errors, duration, throttling, concurrency, cold starts, memory behavior, and downstream dependencies. Distributed traces and correlated logs help explain the causes behind those metrics.