AWS Lambda
Serverless compute service that runs code in response to events
Imagine you need to hire someone to do a specific job, but you only want to pay them for the exact seconds they're working, not for coffee breaks, not for sitting idle. Lambda is like having an infinite pool of workers who appear instantly when there's work to do, complete the task in milliseconds or minutes, then vanish. You don't manage the workers, don't give them desks, don't worry about them getting sick. You just write down the instructions (your code), and whenever an event happens: a file uploaded, a button clicked, a timer going off, a worker appears, executes your instructions, and disappears. You pay only for the compute time consumed, measured in milliseconds. It's the ultimate 'pay for what you use' model.
Lambda is a Function-as-a-Service (FaaS) platform that runs code in response to triggers without servers. You upload code (Node.js, Python, Java, Go, .NET, Ruby, or custom runtimes), configure memory (128MB to 10GB; CPU scales proportionally), and set a timeout (up to 30 minutes; Lambda Managed Instances allow 90 minutes for asynchronous and event-source-mapping calls). Lambda runs each function in an isolated execution environment (microVM) and scales automatically: if 1,000 events arrive at once, Lambda launches 1,000 concurrent executions (up to account limits).
Key Capabilities
- Runs code in response to triggers including API Gateway, S3 events, DynamoDB streams, EventBridge rules, and SQS messages
- Scales automatically from zero to thousands of concurrent executions without any capacity planning
- Supports up to 30-minute execution time (90 minutes on Lambda Managed Instances for asynchronous calls), 10GB memory, and 10GB ephemeral /tmp storage per invocation
- Layers allow shared libraries and dependencies to be packaged separately and reused across multiple functions
- Provisioned Concurrency keeps execution environments pre-initialized to eliminate cold start latency for latency-sensitive workloads
- Destinations route asynchronous invocation results (success or failure) to SQS, SNS, EventBridge, or another Lambda function
Gotchas & Constraints
Gotcha #1: Cold starts: a first or post-idle invocation takes 100ms-1s to initialize the environment; keep functions warm with provisioned concurrency or accept the latency. Gotcha #2: Lambda functions are stateless; data needed between invocations must live externally (S3, DynamoDB, ElastiCache). Constraints: 30-minute max execution time (Step Functions for longer workflows), 10GB max memory, 10GB configurable /tmp storage, and a 6MB synchronous payload limit (use S3 for large data). Newer modes include Lambda Managed Instances (EC2-backed, GPU capable), Web Functions, and durable functions that checkpoint.
Illustrative scenario; figures are examples, not verified customer results.
An e-commerce platform processes order confirmations. Previously, they ran EC2 instances 24/7 to handle order processing, even though orders only came in sporadically, with a peak of 500/minute during sales, but averaging 10/minute overnight. With Lambda, they trigger a function whenever an order is placed (via EventBridge from their order service). The Lambda function validates the order, charges the credit card via Stripe API, updates inventory in DynamoDB, sends a confirmation email by SES, and publishes an event to SNS for downstream systems (shipping, analytics). During a flash sale, Lambda automatically scales to 500 concurrent executions without configuration changes. Cost dropped from $800/month (EC2 instances running 24/7) to $120/month (Lambda charges only for actual execution time). Bonus: no server patching, no capacity planning, no scaling configuration.