AWS Lambda
A serverless compute service that runs code without server management, using a fully pay-per-use model based on request count and execution duration
Overview
AWS Lambda is a serverless compute service that lets you run code without provisioning or managing servers. It automatically executes functions in response to events from over 200 AWS services, such as file uploads to S3, HTTP requests via API Gateway, and data changes in DynamoDB. It supports major runtimes including Python, Node.js, Java, Go, and .NET, and also allows deployment via container images. A perpetual free tier of 1 million requests and 400,000 GB-seconds per month means small applications can run at virtually no cost. The maximum execution time is 15 minutes, and memory can be configured up to 10 GB.
Choosing Between Synchronous, Asynchronous, and Event Source Mapping Invocations
Lambda supports three invocation models, each suited to different use cases. Synchronous invocations (such as HTTP requests via API Gateway or SDK calls) block the caller until the function returns a response, making them ideal for request-response patterns like API backends. Asynchronous invocations (triggered by S3 event notifications, SNS, or EventBridge) queue events internally and process them without the caller waiting - Lambda automatically retries twice on failure and can route failed events to a dead-letter queue or on-failure destination. Event source mappings pull records in batches from streaming and queue services like SQS, Kinesis, and DynamoDB Streams, with Lambda managing the polling, batching, and checkpointing. Choosing the right model affects error handling strategy, cost, and latency characteristics. The default concurrent execution limit is 1,000 per region, but this can be increased to tens of thousands through a limit increase request.
Cold Start Causes and Mitigation Strategies
A cold start occurs when Lambda creates a new execution environment, involving downloading the deployment package, initializing the runtime, and running initialization code. This adds several hundred milliseconds to a few seconds of latency on the first invocation. The primary factors affecting cold start duration are deployment package size, runtime choice (Java and .NET tend to have longer cold starts than Python and Node.js), and the amount of initialization code (such as establishing database connections). Provisioned Concurrency eliminates cold starts by keeping execution environments warm in advance, though charges apply during the idle period. For Java runtimes, SnapStart takes a snapshot of the initialized environment and restores it on invocation, reducing cold start times by up to 90%. For a systematic study of serverless development from basics to advanced topics, books (Amazon) are a great resource. Azure Functions' Consumption plan has a default execution timeout of 10 minutes compared to Lambda's 15-minute limit, though Azure's Premium plan removes this restriction entirely.
Step Functions Integration and Deployment Strategies
When combined with Step Functions, you can build workflows that orchestrate multiple Lambda functions with sequencing, parallel execution, branching, and error handling. Step Functions Express Workflows handle high-volume, short-duration tasks (up to 5 minutes) at lower cost, while Standard Workflows support long-running processes (up to 1 year) with exactly-once execution semantics. A common pattern is using Step Functions to coordinate a data processing pipeline where one Lambda validates input, another transforms data, and a third writes results - with automatic retry and error handling at each step. For deployment, Infrastructure as Code management using AWS SAM or the Serverless Framework is recommended. SAM's local testing capabilities (sam local invoke) let you test functions locally before deploying, and integrating with CI/CD pipelines through CodePipeline or GitHub Actions makes deployment automation straightforward. Canary and linear deployment strategies via CodeDeploy gradually shift traffic to new function versions, reducing the blast radius of faulty deployments.