AWS Lambda is a serverless compute service that lets you run code in response to events without provisioning or managing servers. You pay only for the compute time consumed — there is no charge when code is not running.
In Azure terms: AWS Lambda = Azure Functions
You upload your function code (or write inline)
You configure a trigger (event source)
When the trigger fires, Lambda automatically:
Allocates compute resources
Runs your function
Scales automatically (from 1 to 1,000+ concurrent executions)
Reports metrics to CloudWatch
Runtime Versions Node.js 18.x, 20.x Python 3.11, 3.12 Java 11, 17, 21 .NET .NET 8 Ruby 3.2 Go provided.al2023 (custom runtime)Custom Runtime Bring your own via Lambda Layers or container images
Trigger Type Examples API API Gateway, Function URL (direct HTTPS) Storage S3 object created/deleted, DynamoDB Streams Messaging SQS, SNS, Kinesis, EventBridge Scheduling EventBridge Scheduler (cron-like) Auth Cognito User Pools (custom auth flows) Other CloudFront (Lambda@Edge), ALB, IoT
Setting Description Memory 128 MB to 10,240 MB (CPU scales proportionally) Timeout 1 second to 15 minutes (900 seconds) Concurrency Up to 1,000 concurrent executions per region (soft limit) Execution Role IAM Role that grants the function permissions Environment Variables Key-value config passed to function at runtime Layers Shared dependencies/libraries across functions VPC Optional — attach to a VPC to access private resources
Metric Price Requests $0.20 per 1 million requests Duration $0.0000166667 per GB-second Free tier 1 million requests/month + 400,000 GB-seconds/month forever
Lambda’s free tier never expires — it’s not limited to the first 12 months.
def lambda_handler ( event , context ) :
# event: the trigger payload (dict)
# context: runtime info (function name, remaining time, etc.)
name = event. get ( ' name ' , ' World ' )
' body ' : json. dumps ( f 'Hello, {name} !' )
A common pattern: API Gateway as the trigger makes Lambda an HTTP endpoint:
Client → API Gateway → Lambda → Response
# Create a Lambda function
aws lambda create-function \
--function-name my-function \
--role arn:aws:iam::123456789012:role/lambda-role \
--handler lambda_function.lambda_handler \
--zip-file fileb://function.zip
# Invoke a Lambda function
--function-name my-function \
--payload ' {"name": "AWS"} ' \
aws lambda update-function-code \
--function-name my-function \
--zip-file fileb://function.zip
Scenario Latency Description Cold start 100ms – 1s+ Lambda spins up a new execution environment Warm start < 10ms overhead Reuses an existing execution environment
Tips to reduce cold starts:
Use Provisioned Concurrency (keeps environments warm, extra cost)
Keep deployment packages small
Use lighter runtimes (Python, Node.js) for latency-sensitive functions
Use Lambda SnapStart (Java only)
Feature AWS Lambda Azure Functions Max timeout 15 minutes 10 minutes (Consumption), unlimited (Dedicated/Flex) Max memory 10 GB 1.5 GB (Consumption) Triggers API GW, S3, SQS, SNS, EventBridge, DynamoDB HTTP, Blob, Queue, Service Bus, Event Hub, Timer Hosting plans No choice — always serverless Consumption, Premium, Dedicated Warm instances Provisioned Concurrency Premium (pre-warmed) Languages Node, Python, Java, .NET, Ruby, Go C#, JS, Python, Java, PowerShell, Go
Keep functions small and single-purpose
Store secrets in AWS Secrets Manager or SSM Parameter Store , not environment variables
Set appropriate timeouts — don’t leave at default 3 seconds for I/O-bound functions
Enable X-Ray tracing for distributed debugging
Use Dead Letter Queues (DLQ) for failed async invocations
Tag functions with environment and team for cost tracking