AWS Lambda 101
- 🔧 Function-as-a-Service (FaaS)
- Short-lived compute functions
Comparison with EC2
- Amazon EC2
- Virtual Servers in the Cloud
- Limited by RAM and CPU
- Continuously running
- Scaling means intervention to add/remove servers
- Amazon Lambda
- Virtual functions – no servers to manage! → serverless
- Limited by time – short executions (up to 15 mins)
- 💡 Not intended for long-running, stateful applications
- Run on-demand
- Scaling is automated!
Benefits of AWS Lambda
- Easy Pricing:
- Pay per request/invocation and compute time
- Free tier → each month includes for free:
- 1 million requests/invocations
- 400k GB-seconds of compute time
- Additional reading: https://aws.amazon.com/lambda/pricing/
- 💡 It is usually very cheap to run AWS Lambda so it’s very popular
- Easy to get more resources per functions (up to 10GB of RAM!)
- Increasing RAM also improves CPU and NW!
- Integration with whole AWS suite of services
- e.g. Easy monitoring through AWS CloudWatch
- Event-Driven: functions get invoked by AWS when needed
- Supports many programming languages
- Node.js (JavaScript), Python, Java, C# (.NET Core)/Powershell, Ruby
- Custom Runtime API (community supported, example Rust or Golang)
- Supports Lambda container images
- The container image must implement the Lambda Runtime API
- ‼️ ECS/Fargate preferred for running arbitrary Docker images!
Examples
Serverless Thumbnail creation
Serverless CRON job