SlideShare a Scribd company logo
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
`

More Related Content

PPTX
Lamba scaffold webinar
PPTX
Local Lambda Debugging
PDF
Microservices with AWS Lambda and the Serverless Framework
PDF
Building a Serverless company with Node.js, React and the Serverless Framewor...
PDF
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
PPTX
Dynamic in C# 4.0
PDF
Building a serverless company on AWS lambda and Serverless framework
PDF
AWS Lambda Function with Kotlin
Lamba scaffold webinar
Local Lambda Debugging
Microservices with AWS Lambda and the Serverless Framework
Building a Serverless company with Node.js, React and the Serverless Framewor...
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Dynamic in C# 4.0
Building a serverless company on AWS lambda and Serverless framework
AWS Lambda Function with Kotlin

What's hot (20)

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

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

PDF
AWS Lambda and Serverless framework: lessons learned while building a serverl...
PDF
Writing and deploying serverless python applications
PDF
State of serverless
PDF
PyConIT 2018 Writing and deploying serverless python applications
PDF
PyConIE 2017 Writing and deploying serverless python applications
PPTX
Lambda and serverless - DevOps North East Jan 2017
PDF
Running R on AWS Lambda by Ana-Maria Niculescu
PPTX
AWS Lambda Features and Uses
PPTX
Amazon Web Services lection 5
PDF
Serverless Computing with AWS
PDF
AWS Lambda
PDF
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
PDF
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
PDF
June Webinar: BoxLang-Dynamic-AWS-Lambda
PDF
Laskar: High-Velocity GraphQL & Lambda-based Software Development Model
PDF
aws lambda & api gateway
PDF
Full Stack Meat Project with Arduino Node AWS Mobile
PDF
Deep Visibility: Logging From Distributed Microservices
PDF
AWS Lambdas are cool - Cheminfo Stories Day 1
PPTX
Going Serverless with AWS Lambda at ReportGarden
AWS Lambda and Serverless framework: lessons learned while building a serverl...
Writing and deploying serverless python applications
State of serverless
PyConIT 2018 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applications
Lambda and serverless - DevOps North East Jan 2017
Running R on AWS Lambda by Ana-Maria Niculescu
AWS Lambda Features and Uses
Amazon Web Services lection 5
Serverless Computing with AWS
AWS Lambda
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
June Webinar: BoxLang-Dynamic-AWS-Lambda
Laskar: High-Velocity GraphQL & Lambda-based Software Development Model
aws lambda & api gateway
Full Stack Meat Project with Arduino Node AWS Mobile
Deep Visibility: Logging From Distributed Microservices
AWS Lambdas are cool - Cheminfo Stories Day 1
Going Serverless with AWS Lambda at ReportGarden
Ad

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Cloud computing and distributed systems.
PPT
Teaching material agriculture food technology
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Empathic Computing: Creating Shared Understanding
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
 
PDF
NewMind AI Weekly Chronicles - August'25 Week I
MYSQL Presentation for SQL database connectivity
madgavkar20181017ppt McKinsey Presentation.pdf
cuic standard and advanced reporting.pdf
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Chapter 3 Spatial Domain Image Processing.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Cloud computing and distributed systems.
Teaching material agriculture food technology
Dropbox Q2 2025 Financial Results & Investor Presentation
Empathic Computing: Creating Shared Understanding
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
 
NewMind AI Weekly Chronicles - August'25 Week I

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?