AWS Lambda — Serverless Compute Service
AWS Lambda lets you run code without provisioning or managing servers. You pay only for the compute time you consume — no charge when your code is not running. It is the core service behind serverless architecture on AWS.
Lambda is a compute service that runs your code in response to events and automatically manages the underlying compute resources.
Launched in 2014, AWS Lambda pioneered the serverless computing model. You upload your code as a "Lambda function" and configure it to trigger from over 200 AWS services or HTTP requests via API Gateway. Lambda handles everything — server provisioning, auto-scaling, patching, and monitoring.
Lambda supports multiple programming languages including Node.js, Python, Java, Go, Ruby, C#, and custom runtimes. Each function runs in a stateless container with a configurable timeout (up to 15 minutes) and memory allocation (up to 10 GB).
Event-driven execution at its core.
Event Source
S3 upload, API call, DynamoDB stream, etc.
Lambda Function
Your code runs in a managed container
Execute Code
AWS runs your function logic
Store / Respond
Result saved to S3, DB, or sent back
When an event occurs (e.g., a file is uploaded to S3), Lambda spins up a container to run your function. If the function is invoked again while still warm, the same container is reused — this is called a "warm start." After periods of inactivity, the container is recycled ("cold start"), causing a slight latency increase on the next invocation.
What makes AWS Lambda powerful for modern applications.
Lambda runs your code on a high-availability compute infrastructure and manages all server administration.
From zero to thousands of concurrent executions in seconds. Lambda scales automatically based on incoming requests.
Billed in millisecond increments. No cost when your function is idle — perfect for intermittent workloads.
Trigger from S3, DynamoDB, SQS, SNS, API Gateway, CloudWatch, EventBridge, and many more.
Manage multiple versions, use aliases for dev/staging/prod, and implement blue/green deployments.
Lambda functions run in a VPC, can access secrets via Secrets Manager, and integrate with IAM roles.
An example of a Lambda function in Python that resizes an image when uploaded to S3.
import boto3
from PIL import Image
import os
s3 = boto3.client('s3')
def lambda_handler(event, context):
# Get bucket & key from S3 event
bucket = event['Records'][0]['s3']['bucket']['name']
key = event['Records'][0]['s3']['object']['key']
# Download, resize, re-upload
download_path = '/tmp/' + key
upload_path = '/tmp/resized-' + key
s3.download_file(bucket, key, download_path)
with Image.open(download_path) as img:
img.thumbnail((300, 300))
img.save(upload_path)
s3.upload_file(upload_path, bucket, 'thumbnails/' + key)
return {'statusCode': 200}
How companies use AWS Lambda in production.
Netflix uses Lambda to automate their content encoding pipeline. When a new video is uploaded, Lambda triggers encoding jobs, validates outputs, and notifies downstream systems.
Capital One processes loan applications using Lambda. Function