3. What is Lambda?
Fully Managed Computing Platform
• run code without owning or leasing servers in AWS
• event-driven, stateless, immutable
• pay for what you use
Completely Outsources Administration
• availability / fault tolerance
• elasticity
• server and OS maintenance
• monitoring, logging
4. Lambda Essentials
• You allocate:
- memory
- execution timeout
• Lambda allocates:
- CPU
- disk I/O
- network I/O
• Supported Languages
- Node.js
- Python (2.7)
- Java (8)
- C#
5. Hello World
console.log('Loading function’);
exports.handler = (event, context, callback) => {
console.log('Received event:’, JSON.stringify(event));
console.log('name =', event.name);
var name = '';
if ('name' in event) {
name = event['name'];
} else {
name = 'World';
}
var greetings = 'Hello ' + name + '!';
console.log(greetings);
callback(null, greetings);
};
6. Deploying a AWS Lambda function from the CLI
> aws lambda create-function
--function-name helloWorld
--zip-file filed:///index.zip
--handle index.handler
--role arn:aws:iam::669172621759:role/lambda_write_dynamodb
--runtime nodejs4.3
--description ‘say hello’
9. Limitations of Lambda
• Throttle limits
- 100 concurrent function executions total
• Resource limits
- 1024 processes / threads
- 1024 file descriptors
- 512 MB ephemeral /tmp space
- maximum execution time: 300 sec
- request/response payload: 6 MB
- 1.5 GB RAM
• Functional limits
- cold start time
- CPU allocation (proportional to memory allocation)
10. Security
• IAM (execution) role
permissions you grant to this role determine what
AWS Lambda function can do
• Lambda (resource) policy
Permission granted to Lambda determine which
service or event can invoke your function
13. Event Driven Architecture
• event-driven means no centralized workflow
• application does not enforce sequence of events
• decoupling of server from receiver
• micro services architecture - distributed
transactions are hard (CAP)
• reactive programming - countless possibilities
14. AWS Lambda Pricing
• by memory and execution time
$0.00001667 per GB-second used
https://s3.amazonaws.com/lambda-tools/pricing-
calculator.html
• but also pay for S3, EC2, DynamoDB