Compute
    Compute

    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 executes code in response to triggers without provisioning 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 (max 15 minutes). Lambda runs your function in an isolated execution environment (microVM) and scales automatically: if 1,000 events arrive simultaneously, Lambda launches 1,000 concurrent executions (up to account limits).

    Key Capabilities

    Key integrations: API Gateway for HTTP APIs, S3 for object events, DynamoDB Streams for database changes, EventBridge for scheduled or custom events, SQS for queue processing.

    Gotchas & Constraints

    Gotcha #1: Cold starts: the first invocation or after idle periods takes 100ms-1s to initialize the execution environment; keep functions warm with provisioned concurrency or accept the latency. Gotcha #2: Lambda functions are stateless; any data you need between invocations must be stored externally (S3, DynamoDB, ElastiCache). Constraints: 15-minute max execution time (use Step Functions for longer workflows), 10GB max memory, up to 10GB configurable /tmp storage, 6MB synchronous invocation payload limit (use S3 for large data).

    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.

    Official AWS Documentation