AWS Lambda
AWS Lambda is a serverless compute service that runs code in response to events without provisioning or managing servers. You pay only for the compute time consumed - there's no charge when code isn't running.
Key Features
- Event-driven: Triggered by AWS services, HTTP requests, or schedules
- Auto-scaling: Scales from zero to thousands of concurrent executions
- Pay-per-use: Billed per 1ms of execution time
- Multiple runtimes: Node.js, Python, Java, Go, .NET, Ruby, and custom runtimes
Common Triggers
| Trigger | Use Case |
|---|---|
| API Gateway | REST/HTTP APIs |
| S3 | File processing |
| DynamoDB Streams | Database change events |
| SQS | Message processing |
| EventBridge | Scheduled tasks, event routing |
| Cognito | Authentication triggers |
Function Configuration
// handler.js
exports.handler = async (event) => {
const name = event.queryStringParameters?.name || 'World';
return {
statusCode: 200,
body: JSON.stringify({ message: `Hello, ${name}!` }),
};
};
Limits and Quotas
| Resource | Limit |
|---|---|
| Timeout | 15 minutes |
| Memory | 128 MB - 10 GB |
| Deployment package | 50 MB (zipped), 250 MB (unzipped) |
| Concurrent executions | 1,000 (soft limit) |
/tmp storage | 512 MB - 10 GB |
What We Like
- Zero infrastructure: No servers to manage, patch, or scale
- Cost efficient: Only pay for actual execution time
- Fast deployment: Push code and it's live
- Tight AWS integration: First-class support throughout AWS
What We Don't Like
- Cold starts: First invocation after idle can be slow
- Stateless: No persistent connections or in-memory state
- Debugging: Local development doesn't perfectly match production
- Vendor lock-in: Lambda-specific patterns can be hard to migrate
Cold Start Mitigation
- Use Provisioned Concurrency for latency-sensitive workloads
- Keep functions warm with scheduled pings
- Choose runtimes wisely (Node.js and Python start faster than Java)
- Minimise deployment package size