Lambda

AWS Lambda is a serverless compute service that runs your code in response to events without requiring you to provision or manage servers. You upload a function, define what triggers it (an HTTP request via API Gateway, a new file in S3, a message in SQS, a DynamoDB change), and Lambda handles everything else — execution, scaling, patching, and availability. Lambda scales automatically from zero to thousands of concurrent invocations, and you pay only for actual compute time measured in milliseconds. Functions can run for up to 15 minutes and can be written in Node.js, Python, Java, Go, Ruby, or custom runtimes. Cross-cloud equivalents: Azure Functions (Azure), Cloud Functions or Cloud Run (GCP), Oracle Functions (OCI). When would you use Lambda? Lambda is ideal for event-driven, short-duration workloads: processing file uploads, responding to API calls through API Gateway, reacting to database change streams, running scheduled tasks (like a cron job via EventBridge), sending notifications, and transforming data between services. It's particularly cost-effective for variable or bursty traffic patterns since you pay nothing when idle. Common mistakes: using Lambda for long-running processes (15-minute maximum execution time is a hard limit — use ECS Fargate or EC2 instead), ignoring cold start latency for latency-sensitive endpoints (use Provisioned Concurrency to keep functions warm), hitting concurrency limits without requesting quota increases in advance, and storing state in the function itself (Lambda functions are stateless — use DynamoDB, ElastiCache, or S3 for persistence between invocations).

Example: An e-commerce site uses Lambda to: process images uploaded to S3 (resizing and watermarking), send order confirmation emails triggered by DynamoDB writes, and run a nightly cost report triggered by EventBridge — all without maintaining any servers. Architecture use case: a real-time data pipeline uses Kinesis Data Streams to ingest clickstream events, Lambda to transform and enrich each record, and S3 + Athena for serverless querying — handling millions of events per day with no servers to provision.

Category: cloud

Difficulty: intermediate