Deploying Web Services
with 

AWS Lambda
Stefan Deusch
Software Delivery at vroozi.com
&
Owner of sunsprinkle.com
February 15, 2017
Agenda
• Lambda Essentials
• Creation of AWS Lambda code
• Limitations of AWS Lambda
• Demo
• Event Driven Architecture
• Questions & Answers
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
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#
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);
};
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’
Event Sources for Lambda
Event Model


- Push (event sources invokes Lambda, S3, SNS,
Cognito, Echo, etc.)


- Pull (Lambda polls event source) DynamoDB,
Kinesis)

- event source is mapped
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)
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 

Demo AWS Lambda 

File Sharing App Flow
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
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
Deployment Frameworks
• AWS CloudFormation (YML, JSON)
• Chalice (Python)
• serverless.com
• Apex.run
• Claudia.js
Thank You
Q & A
References
• AWS Lambda in Action, Danilo Poccia, Manning
• LinuxAcademy - Lambda Deep Dive

SoCal NodeJS Meetup 20170215_aws_lambda

  • 1.
    Deploying Web Services with
 AWS Lambda Stefan Deusch Software Delivery at vroozi.com & Owner of sunsprinkle.com February 15, 2017
  • 2.
    Agenda • Lambda Essentials •Creation of AWS Lambda code • Limitations of AWS Lambda • Demo • Event Driven Architecture • Questions & Answers
  • 3.
    What is Lambda? FullyManaged 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 • Youallocate:
 - 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 AWSLambda 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’
  • 7.
    Event Sources forLambda Event Model 
 - Push (event sources invokes Lambda, S3, SNS, Cognito, Echo, etc.) 
 - Pull (Lambda polls event source) DynamoDB, Kinesis)
 - event source is mapped
  • 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 

  • 11.
  • 12.
  • 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
  • 15.
    Deployment Frameworks • AWSCloudFormation (YML, JSON) • Chalice (Python) • serverless.com • Apex.run • Claudia.js
  • 16.
    Thank You Q &A References • AWS Lambda in Action, Danilo Poccia, Manning • LinuxAcademy - Lambda Deep Dive