SlideShare uma empresa Scribd logo
1 de 47
Lessons Learned After a Year of AWS Lambda
● AWS Lambda Overview
● Performance characteristics
● Lambda Integration
● Debugging AWS Lambda
Agenda:
AWS Lambda Overview
AWS Lambda
● Created in 2014, launched at
re:Invent
● Kicked off "serverless" (caveat)
● Function-as-a-Service
○Deploy code, not applications
AWS Lambda Details
● Supports Node.JS, Python, C#, and
Java
● Can call to server functionality
● Code deployment options
○ Uploading as a ZIP file (S3 or HTTP)
○ In-browser editor
Calling AWS Lambda Functions
● Event-based triggers
○ On-Demand via HTTP
● Event Sources
○ AWS Services (S3, DynamoDB, others)
○ API Gateway
○ AWS SDK
Creating a Lambda Function
(in pictures)
Demo
Demo
Demo
Demo
Demo
Demo
Performance Characteristics
● Scraped logs of 2.6 million function
calls
● Pulled from CloudWatch on AWS
○ Function execution only
● Data on computing resources
consumed only
Examining Lambda Performance
● Graphs built on a sample of full data set
(26,000 vs 2.6 million)
○ Sample is not random
● No relation to size of Lambda function
● Confounding factors may be present
● Significant outliers
First, Caveats
Memory vs Execution Time
Memory vs Execution Time
● Does not incorporate HTTP Request
● Not a very strong correlation (r=-0.03)
● Three distinct groupings
● Tip: More memory allocated = faster
processor
Runtime Histogram
Runtime Histogram
● Many functions run in < 100 ms
● Ignores code characteristics
● Ignores significant outliers on both ends
● Bimodal due to function characteristics
Improving the Analysis
● Capture full cycle times if possible
● Correlate runtimes with size of function
● Algorithmic complexity analysis
● Randomize sample selection
Lambda Integration
Four problems to solve:
● Problem 1 - Lambda Ownership
● Problem 2 - Deduplication
● Problem 3 - Triggering Lambda Functions
● Problem 4 - User Security
Lambda Integration
Problem 1 - Lambda Ownership
Option 1: User ownership
● Users host Lambda functions in their AWS
account
● Backand uses provided credentials to call
Lambda
● Maximizes freedom at the expense of ease of
use (also, security)
Problem 1 - Lambda Ownership
Option 2: Backand ownership
● Backand hosts Lambda functions in internal
AWS account
● No need for user's AWS credentials
● Maximizes ease of use at expense of user
freedom
Solution selected: Backand owns code
● Lambda function names need to be unique
● Name length limits:
○ 140 characters for full ARN
○ 64 character subset for function name
Solution Selected: prepend guaranteed unique data
● Backand app names have a uniqueness constraint
● Could also use GUID, but this reduces name length
to 32 characters
Problem 2 - Deduplication
● Most triggers AWS-based
○ S3, DynamoDB, Cloudwatch
○ None work for our use case
● API Gateway
○ Positive: Allows HTTP trigger
○ Negative: Complex configuration
○ Negative: Return value requirements
Solution selected: AWS SDK
Problem 3 - Triggering Lambda
● Default: configure IAM profile and users
○ Need to give every dev access to AWS
○ Does not integrate with org security
○ Needs to be managed in multiple places
● Clients want flexibility and security
○ Need Single Sign-On
○ Need custom third-party security tools
○ Need ease of management
Solution selected: Lambda Launcher
Problem 4 - User Security
Debugging AWS Lambda
Debugging Lambda Functions
● Cloudwatch Integration
○ Provides call record, and console.log()
● Custom parameter input
○ Modal dialog presented before each run
● … and that's it
Emulating Lambda Locally
Three things to mimic:
● Trigger Event
● Machine Environment
● Invocation
Emulating trigger event
● Each trigger sends different data
● Dump data from a sample call
(console.log())
● Keep in mind any transformations (API
Gateway)
Lambda Machine Environment
● Based on Amazon Machine Instance
● Dynamically provisioned (hot vs cold)
● Temporary storage (/tmp, 500 MB)
○ NOT guaranteed to persist
● Cannot accurately model machine
Invoking Lambda
● External Function Call (entry point)
● Custom parameters in "event" object
● Execution context details in "context"
● Callbacks (if supported) in "callback"
Debugging Lambda Locally
● Execution environment hard to
emulate
● Need to mimic input format from
action
● Need to mimic output format
● Need a test harness
Creating a Test Harness (Node.js)
● Function Prototype
● Including Handler
● Mimicking Lambda Invocation
○ Parameters in event object
○ Handlers in the context object
Creating a Test Harness
● Calling a Lambda function
Test Harness Notes
● Callback mechanism
○ Need to adapt for each language
● Using callbacks in context parameter
○ Not supported, overloads context object
● Not a perfect substitute
○ Calls the function, but not from the same
environment
What do we get?
● Per-line output via console.log
● Immediate feedback from command
● Breakpoints and other local debugging
tools
● Unit and Integration tests
● CI/CD compatible (with CLI)
Deploying Your Code
● Zip-file from S3, or manual upload
○ Gotcha: zip only the source
code, not the parent folder!
● Test upload
● Publish new API
● Complex, non-intuitive
Using Backand's CLI Tool
● Backand On-Demand Node.JS
Lambda Functions
● Backand CLI abstracts away
deployment
● npm install -g backand
● Requires registering with Backand
Lambda through a CLI
● Initialize a function
○ backand function init
● Copy your Node.JS code into created
directory and iterate
● Deploy
○ backand function deploy
Calling Your Lambda
● Authentication
○ can be anonymous
○ api.backand.com/1/token
● cURL
curl -H "<auth header>" "https://api.backand.com/1/function/general/<name>"
● JavaScript (with Backand SDK)
backand.function.get(...)
What is Backand?
● Serverless app platform
● Manages your app's database
● Manages your app's security and
authentication
● Provides custom server-side code execution
● Provides hosting options
● Provides logging, analytics, and more
Backand Features
● Automated REST API
● Bring your own Database
● Custom JavaScript Actions
● Server-Side Code Execution
● Batch and Bulk Processing
● Scheduled Tasks
● Automated messages
● Real-time Communications
● User and Role-based
Security
● Social Media Authentication
● GUI Schema Editor
● Custom Queries
● REST API Playground
● Sample Code Generation
● Hosting
● Detailed Analytics
● Logging
● Multi-Platform SDK
● Single Sign On Support
● Live online demo every other Wednesday
● Webinar - Invoking Lambda through Alexa
Thursday, June 22nd, 11 AM Pacific
Learn more at https://www.backand.com
Want to know more?
THANK YOU
https://github.com/backand
matt@backand.com
@matt_billock
`

Mais conteúdo relacionado

Mais procurados

Reactive programming using rx java & akka actors - pdx-scala - june 2014
Reactive programming   using rx java & akka actors - pdx-scala - june 2014Reactive programming   using rx java & akka actors - pdx-scala - june 2014
Reactive programming using rx java & akka actors - pdx-scala - june 2014
Thomas Lockney
 

Mais procurados (20)

Aws Lambda in Swift - NSLondon - 3rd December 2020
Aws Lambda in Swift - NSLondon - 3rd December 2020Aws Lambda in Swift - NSLondon - 3rd December 2020
Aws Lambda in Swift - NSLondon - 3rd December 2020
 
Turbo charging v8 engine
Turbo charging v8 engineTurbo charging v8 engine
Turbo charging v8 engine
 
Testing Spark and Scala
Testing Spark and ScalaTesting Spark and Scala
Testing Spark and Scala
 
AWS Step Function with API Gateway Integration - Metin Kale, Chicago
AWS Step Function with API Gateway Integration - Metin Kale, ChicagoAWS Step Function with API Gateway Integration - Metin Kale, Chicago
AWS Step Function with API Gateway Integration - Metin Kale, Chicago
 
Fast Deployments to Multiple Golang Lambda Functions
Fast Deployments to Multiple Golang Lambda FunctionsFast Deployments to Multiple Golang Lambda Functions
Fast Deployments to Multiple Golang Lambda Functions
 
Logging in Scala
Logging in ScalaLogging in Scala
Logging in Scala
 
Understanding Implicits in Scala
Understanding Implicits in ScalaUnderstanding Implicits in Scala
Understanding Implicits in Scala
 
2020.02.15 DelEx - CI/CD in AWS Cloud
2020.02.15 DelEx - CI/CD in AWS Cloud2020.02.15 DelEx - CI/CD in AWS Cloud
2020.02.15 DelEx - CI/CD in AWS Cloud
 
Dynamic input tables lwc vs aura vs. visualforce
Dynamic input tables  lwc vs aura vs. visualforceDynamic input tables  lwc vs aura vs. visualforce
Dynamic input tables lwc vs aura vs. visualforce
 
Reactive programming using rx java & akka actors - pdx-scala - june 2014
Reactive programming   using rx java & akka actors - pdx-scala - june 2014Reactive programming   using rx java & akka actors - pdx-scala - june 2014
Reactive programming using rx java & akka actors - pdx-scala - june 2014
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scala
 
Aws Developer Associate Overview
Aws Developer Associate OverviewAws Developer Associate Overview
Aws Developer Associate Overview
 
The Fn Project by Jesse Butler
 The Fn Project by Jesse Butler The Fn Project by Jesse Butler
The Fn Project by Jesse Butler
 
Serverless Boston @ Oracle Meetup
Serverless Boston @ Oracle MeetupServerless Boston @ Oracle Meetup
Serverless Boston @ Oracle Meetup
 
OSDC 2018 - Distributed monitoring
OSDC 2018 - Distributed monitoringOSDC 2018 - Distributed monitoring
OSDC 2018 - Distributed monitoring
 
Serverless
ServerlessServerless
Serverless
 
Python Streaming Pipelines with Beam on Flink
Python Streaming Pipelines with Beam on FlinkPython Streaming Pipelines with Beam on Flink
Python Streaming Pipelines with Beam on Flink
 
Go lambda-presentation
Go lambda-presentationGo lambda-presentation
Go lambda-presentation
 
Productionalizing Spark ML
Productionalizing Spark MLProductionalizing Spark ML
Productionalizing Spark ML
 
Flink Forward Berlin 2017: Dominik Bruhn - Deploying Flink Jobs as Docker Con...
Flink Forward Berlin 2017: Dominik Bruhn - Deploying Flink Jobs as Docker Con...Flink Forward Berlin 2017: Dominik Bruhn - Deploying Flink Jobs as Docker Con...
Flink Forward Berlin 2017: Dominik Bruhn - Deploying Flink Jobs as Docker Con...
 

Semelhante a Lessons learned after a year of lambda - AWS Community Day SF 2017

AWS Lambda and Serverless framework: lessons learned while building a serverl...
AWS Lambda and Serverless framework: lessons learned while building a serverl...AWS Lambda and Serverless framework: lessons learned while building a serverl...
AWS Lambda and Serverless framework: lessons learned while building a serverl...
Luciano Mammino
 

Semelhante a Lessons learned after a year of lambda - AWS Community Day SF 2017 (20)

AWS Lambda and Serverless framework: lessons learned while building a serverl...
AWS Lambda and Serverless framework: lessons learned while building a serverl...AWS Lambda and Serverless framework: lessons learned while building a serverl...
AWS Lambda and Serverless framework: lessons learned while building a serverl...
 
Writing and deploying serverless python applications
Writing and deploying serverless python applicationsWriting and deploying serverless python applications
Writing and deploying serverless python applications
 
State of serverless
State of serverlessState of serverless
State of serverless
 
PyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applicationsPyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applications
 
PyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsPyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applications
 
Lambda and serverless - DevOps North East Jan 2017
Lambda and serverless - DevOps North East Jan 2017Lambda and serverless - DevOps North East Jan 2017
Lambda and serverless - DevOps North East Jan 2017
 
Running R on AWS Lambda by Ana-Maria Niculescu
Running R on AWS Lambda by Ana-Maria NiculescuRunning R on AWS Lambda by Ana-Maria Niculescu
Running R on AWS Lambda by Ana-Maria Niculescu
 
AWS Lambda Features and Uses
AWS Lambda Features and UsesAWS Lambda Features and Uses
AWS Lambda Features and Uses
 
Amazon Web Services lection 5
Amazon Web Services lection 5  Amazon Web Services lection 5
Amazon Web Services lection 5
 
AWS October Webinar Series - AWS Lambda Best Practices: Python, Scheduled Job...
AWS October Webinar Series - AWS Lambda Best Practices: Python, Scheduled Job...AWS October Webinar Series - AWS Lambda Best Practices: Python, Scheduled Job...
AWS October Webinar Series - AWS Lambda Best Practices: Python, Scheduled Job...
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
AWS Lambda in C#
AWS Lambda in C#AWS Lambda in C#
AWS Lambda in C#
 
AWS Lambda and the Serverless Cloud
AWS Lambda and the Serverless CloudAWS Lambda and the Serverless Cloud
AWS Lambda and the Serverless Cloud
 
Serverless Computing with AWS
Serverless Computing with AWSServerless Computing with AWS
Serverless Computing with AWS
 
AWS Lambda
AWS LambdaAWS Lambda
AWS Lambda
 
NEW LAUNCH! Developing Serverless C# Applications
NEW LAUNCH! Developing Serverless C# ApplicationsNEW LAUNCH! Developing Serverless C# Applications
NEW LAUNCH! Developing Serverless C# Applications
 
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
Skillenza Build with Serverless Challenge -  Advanced Serverless ConceptsSkillenza Build with Serverless Challenge -  Advanced Serverless Concepts
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
 
Laskar: High-Velocity GraphQL & Lambda-based Software Development Model
Laskar: High-Velocity GraphQL & Lambda-based Software Development ModelLaskar: High-Velocity GraphQL & Lambda-based Software Development Model
Laskar: High-Velocity GraphQL & Lambda-based Software Development Model
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
aws lambda & api gateway
aws lambda & api gatewayaws lambda & api gateway
aws lambda & api gateway
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Lessons learned after a year of lambda - AWS Community Day SF 2017

  • 1. Lessons Learned After a Year of AWS Lambda
  • 2. ● AWS Lambda Overview ● Performance characteristics ● Lambda Integration ● Debugging AWS Lambda Agenda:
  • 4. AWS Lambda ● Created in 2014, launched at re:Invent ● Kicked off "serverless" (caveat) ● Function-as-a-Service ○Deploy code, not applications
  • 5. AWS Lambda Details ● Supports Node.JS, Python, C#, and Java ● Can call to server functionality ● Code deployment options ○ Uploading as a ZIP file (S3 or HTTP) ○ In-browser editor
  • 6. Calling AWS Lambda Functions ● Event-based triggers ○ On-Demand via HTTP ● Event Sources ○ AWS Services (S3, DynamoDB, others) ○ API Gateway ○ AWS SDK
  • 7. Creating a Lambda Function (in pictures)
  • 10. Demo
  • 11. Demo
  • 12. Demo
  • 13. Demo
  • 15. ● Scraped logs of 2.6 million function calls ● Pulled from CloudWatch on AWS ○ Function execution only ● Data on computing resources consumed only Examining Lambda Performance
  • 16. ● Graphs built on a sample of full data set (26,000 vs 2.6 million) ○ Sample is not random ● No relation to size of Lambda function ● Confounding factors may be present ● Significant outliers First, Caveats
  • 18. Memory vs Execution Time ● Does not incorporate HTTP Request ● Not a very strong correlation (r=-0.03) ● Three distinct groupings ● Tip: More memory allocated = faster processor
  • 20. Runtime Histogram ● Many functions run in < 100 ms ● Ignores code characteristics ● Ignores significant outliers on both ends ● Bimodal due to function characteristics
  • 21. Improving the Analysis ● Capture full cycle times if possible ● Correlate runtimes with size of function ● Algorithmic complexity analysis ● Randomize sample selection
  • 23. Four problems to solve: ● Problem 1 - Lambda Ownership ● Problem 2 - Deduplication ● Problem 3 - Triggering Lambda Functions ● Problem 4 - User Security Lambda Integration
  • 24. Problem 1 - Lambda Ownership Option 1: User ownership ● Users host Lambda functions in their AWS account ● Backand uses provided credentials to call Lambda ● Maximizes freedom at the expense of ease of use (also, security)
  • 25. Problem 1 - Lambda Ownership Option 2: Backand ownership ● Backand hosts Lambda functions in internal AWS account ● No need for user's AWS credentials ● Maximizes ease of use at expense of user freedom Solution selected: Backand owns code
  • 26. ● Lambda function names need to be unique ● Name length limits: ○ 140 characters for full ARN ○ 64 character subset for function name Solution Selected: prepend guaranteed unique data ● Backand app names have a uniqueness constraint ● Could also use GUID, but this reduces name length to 32 characters Problem 2 - Deduplication
  • 27. ● Most triggers AWS-based ○ S3, DynamoDB, Cloudwatch ○ None work for our use case ● API Gateway ○ Positive: Allows HTTP trigger ○ Negative: Complex configuration ○ Negative: Return value requirements Solution selected: AWS SDK Problem 3 - Triggering Lambda
  • 28. ● Default: configure IAM profile and users ○ Need to give every dev access to AWS ○ Does not integrate with org security ○ Needs to be managed in multiple places ● Clients want flexibility and security ○ Need Single Sign-On ○ Need custom third-party security tools ○ Need ease of management Solution selected: Lambda Launcher Problem 4 - User Security
  • 30. Debugging Lambda Functions ● Cloudwatch Integration ○ Provides call record, and console.log() ● Custom parameter input ○ Modal dialog presented before each run ● … and that's it
  • 31. Emulating Lambda Locally Three things to mimic: ● Trigger Event ● Machine Environment ● Invocation
  • 32. Emulating trigger event ● Each trigger sends different data ● Dump data from a sample call (console.log()) ● Keep in mind any transformations (API Gateway)
  • 33. Lambda Machine Environment ● Based on Amazon Machine Instance ● Dynamically provisioned (hot vs cold) ● Temporary storage (/tmp, 500 MB) ○ NOT guaranteed to persist ● Cannot accurately model machine
  • 34. Invoking Lambda ● External Function Call (entry point) ● Custom parameters in "event" object ● Execution context details in "context" ● Callbacks (if supported) in "callback"
  • 35. Debugging Lambda Locally ● Execution environment hard to emulate ● Need to mimic input format from action ● Need to mimic output format ● Need a test harness
  • 36. Creating a Test Harness (Node.js) ● Function Prototype ● Including Handler ● Mimicking Lambda Invocation ○ Parameters in event object ○ Handlers in the context object
  • 37. Creating a Test Harness ● Calling a Lambda function
  • 38. Test Harness Notes ● Callback mechanism ○ Need to adapt for each language ● Using callbacks in context parameter ○ Not supported, overloads context object ● Not a perfect substitute ○ Calls the function, but not from the same environment
  • 39. What do we get? ● Per-line output via console.log ● Immediate feedback from command ● Breakpoints and other local debugging tools ● Unit and Integration tests ● CI/CD compatible (with CLI)
  • 40. Deploying Your Code ● Zip-file from S3, or manual upload ○ Gotcha: zip only the source code, not the parent folder! ● Test upload ● Publish new API ● Complex, non-intuitive
  • 41. Using Backand's CLI Tool ● Backand On-Demand Node.JS Lambda Functions ● Backand CLI abstracts away deployment ● npm install -g backand ● Requires registering with Backand
  • 42. Lambda through a CLI ● Initialize a function ○ backand function init ● Copy your Node.JS code into created directory and iterate ● Deploy ○ backand function deploy
  • 43. Calling Your Lambda ● Authentication ○ can be anonymous ○ api.backand.com/1/token ● cURL curl -H "<auth header>" "https://api.backand.com/1/function/general/<name>" ● JavaScript (with Backand SDK) backand.function.get(...)
  • 44. What is Backand? ● Serverless app platform ● Manages your app's database ● Manages your app's security and authentication ● Provides custom server-side code execution ● Provides hosting options ● Provides logging, analytics, and more
  • 45. Backand Features ● Automated REST API ● Bring your own Database ● Custom JavaScript Actions ● Server-Side Code Execution ● Batch and Bulk Processing ● Scheduled Tasks ● Automated messages ● Real-time Communications ● User and Role-based Security ● Social Media Authentication ● GUI Schema Editor ● Custom Queries ● REST API Playground ● Sample Code Generation ● Hosting ● Detailed Analytics ● Logging ● Multi-Platform SDK ● Single Sign On Support
  • 46. ● Live online demo every other Wednesday ● Webinar - Invoking Lambda through Alexa Thursday, June 22nd, 11 AM Pacific Learn more at https://www.backand.com Want to know more?