AWS Lambda Presentation (Tech Talk DC)

Doguhan Uluca
Doguhan UlucaJavaScript Specialty Lead at Excella Consulting
Who Am I ?
By day:
Technical Program Manager
• National Rural Electric Cooperative Association
• Large 40M+ Angular, Backbone.JS, .Net WebApi
• application
By night
JavaScript Extraordinaire
Co-Founder & Chief Engineer for Hoozip.com
• Angular
• AWS S3
• AWS Lambda
• AWS Api Gateway
• AWS EC2
@javascriptbully
• Mongo
• Express
• Angular
• NodeJS
• AWS
• NodeJS
• Angular
• Lambda
@javascriptbully
“Time to get Mean!”
?
Who Am I ?
Time to get
A.N.A.L !!!!!
Event-Driven Compute
• As data enters your cloud infrastructure Lambda makes it extremely easy to
transform that data by applying your function to the data based on events you
define.
• Examples include data transformation, image transformation, large scale data
analysis. For example, run transformation functions whenever a DynamoDB
table is loaded.
• Ability to scale horizontally across large scale work loads and dynamically then
instantly shrink back once the work is complete.
• 100 concurrent executions
• 1,000 invokes per second
Quickly build mobile Backends
• AWS mobile SDKs
Lambda offering overview
• Runs code in response to events
• Object uploads to Amazon S3
• Updates to Amazon DynamoDB via Streams
• Data in Amazon Kinesis Streams
• In app activity
• Lambda handles all capacity, scaling, patching and infrastructure administration
• Lambda only runs your code when triggered so you don’t have to pay for unused capacity
• Provides realtime metrics and logs to Amazon CloudWatch
• Low cost, No upfront costs
• Code is charged in measurements of 100ms increments
• Python, Java, NodeJs
• Lambda Function (Micro service architecture)
• Prebuilt examples
• Built in support for AWS SDK
• AWS Free Tier you can try Lambda for free
• Security is baked in
Lambda offering overview (cont’d)
AWS Lambda supports the following runtime versions
• Node.js: v0.10.36
• Java: Java 8
• Python: Python 2.7
If you author your Lambda function code in Node.js,
the following libraries are available in the AWS Lambda
execution environment so you don't need to include
them:
• ImageMagick: Installed with default settings. For
versioning information, see imagemagick nodejs
wrapper and ImageMagick native binary
(search for "ImageMagick").
• AWS SDK: AWS SDK for JavaScript version
2.2.32
If you author your Lambda function code in Python, the
following libraries are available in the AWS Lambda
execution environment so you don't need to include
them:
• AWS SDK for Python (Boto 3) version 1.2.3
There are no additional libraries available for Java.
Hoozip Use Case
• Want to send property reports on demand via SMS
• Wanted to follow an event driven, micro service design
• Scale our systems up or down when certain load metrics are hit
• Send out notifications to owners of properties when their property is requested
• Managing and reacting to all those events would require a complex infrastructure, so
often we simply put them together in one controller action or use observers that run in
the same processes as our applications. This makes the codebase more complex as
parts start getting interwoven.
• Most teams start pushing those tasks into background workers, but the infrastructure
necessary for managing tasks this way is overhead too. Therefore, background
workers are typically limited to the most important tasks. This is especially true when
they don’t get automatically triggered by events, but need to be triggered through the
codebase. Doing this adds another level of complexity to the code in order to
understand which part triggers which event.
• It lets you write small NodeJS functions that will be called with the event metadata
from events triggered by various services or through your own code.
Hoozip
• Hoozip.com is a marketplace and software provider for real estate investors
(rehabbers, wholesalers, lenders) to find, post, and curate real estate
investment deals in an efficient way.
What we normally would do
• Size Provision Scale Servers
• Estimate capacity
• Run fault tolerance
• Manage Operating System
Updates
• Apply Security Patches
• Monitor for performance and
availability
• Lambda does the
impedance matching for
your event flow so you don’t
have to worry about over or
under provisioning as
Lambda scales elastically
call twilio
post to ApiGateway
call Lambda
parse message
fuzzy address
geoCode address
call property API
call bitly API
persist to DynamoDB
generate message
post back to twiliosend message
How we did it…
* As the API get’s busier, we’ll add a queueing / push
notification mechanism via SQS & SNS
TEXT YOUR DEAL
ADDRESS
TO HOOZIP!
(202) 798-1333
Hoozip Architecture
• We serve our Angular app out of a S3 Bucket
• We use CloudFront as our CDN for all static assets including
the Angular App
• Most of our services are separate stand alone projects and
handled via Api Gateway and Lambda
• We currently use DynamoDB for persisting and Postgres as
our store for financial related actions and some GeoSpatial
calculations.
• When we can’t use Lambda (static IP addressing,
computationally heavy work loads) we use EC2 with Node
v4.0, Express, served via Node Forever and NodeMon
LET’S CODE!!!!
enough of that
What’s available while programming in Node?
• Lambda Function Handler
• Event Object
• Context Object
• ImageMagick available (Node.js)
• Logging & Monitoring (CloudWatch & CloudTrail)
• Exceptions
• Ephemeral I/O operations while function is executing
• Awesome! But the worst part:
• Node v0.10.36
• http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html
Code via the online code editor, or in your own IDE
• Let’s build a simple API that goes out to Github, and get’s a user object.
• Here’s our Lambda function:
Testing your Lambda function locally
• Easy to test your logic locally
• Easy to turn this into an express module that you can then use
to serve via an api somewhere else so you’re not bound to
Lambda if you decide to move at a later date.
Upload your code
• Compress the items in you source
folder.
• Upload the zip file directly to your
Lamda function via the console.
• Better if you use a task manager like
Gulp that will zip the file and upload it
for you via the AWS SDK publish API
• I prefer to use Gulp to zip my code, then
upload to S3 so I have artifact
versioning as well. I wrote another
Lambda functions that listens for upload
events on that bucket then imports the
code into my Lambda function.
Now let’s create an API in API Gateway
that integrates with our Lambda Function
Let’s setup our API to have a query string parameter
called ‘name’ that we pass into our Lambda Function
Next we map the data retrieved byApi Gateway
to the Event object passed into our Lambda Function
via the mapping template
Let’s deploy our Api to a stage called ‘prod’!
Staging allows you to create various versions of your
Api for testing, different clients, etc…
And we’re done!
Instantly scalable to millions of users!
Here’s my Lambda function that
deploys other Lambda Functions
• Event source for this Lambda function in my S3 bucket where I upload my
Lambda zip files
• Uses the AWS SDK which is already loaded into memory by AWS.
Pricing Details
• No hourly, daily, monthly minimums
• No per device fees
• Compute time is purchased in 100ms increments
• 1M requests and 400,000 GB-s of compute every month for free
• You only pay when you’re doing work, not when you’re idle.
Requests
You are charged for the total number of requests across all your functions. Lambda counts a request
each time it starts executing in response to an event notification or invoke call, including test invokes
from the console.
• First 1 million requests per month are free
• $0.20 per 1 million requests thereafter ($0.0000002 per request)
Duration
Duration is calculated from the time your code begins executing until it returns or otherwise terminates,
rounded up to the nearest 100ms. The price depends on the amount of memory you allocate to your
function. You are charged $0.00001667 for every GB-second used.
Free Tier
The Lambda free tier includes 1M free requests per month and 400,000 GB-seconds of compute time
per month. The memory size you choose for your Lambda functions determines how long they can run in
the free tier. The Lambda free tier does not automatically expire at the end of your 12 month AWS Free
Tier term, but is available to both existing and new AWS customers indefinitely.
Monthly compute charges
The monthly compute price is $0.00001667 per
GB-s and the free tier provides 400,000 GB-s.
Total compute (seconds) = 30M * (0.2sec) =
6,000,000 seconds
Total compute (GB-s) = 6,000,000 * 128MB/1024
= 750,000 GB-s
Total Compute – Free tier compute = Monthly
billable compute seconds
750,000 GB-s – 400,000 free tier GB-s = 350,000
GB-s
Monthly compute charges = 350,000 *
$0.00001667 = $5.83
Monthly request charges
The monthly request price is $0.20
per 1 million requests and the free
tier provides 1M requests per month.
Total requests – Free tier request =
Monthly billable requests
30M requests – 1M free tier requests
= 29M Monthly billable requests
Monthly request charges = 29M *
$0.2/M = $5.80
Total compute charges
Total charges = Compute charges
+ Request charges = $5.83 + $5.80
= $11.63 per month
Pricing Example
If you allocated 128MB of memory to your function, executed it 30 million times in one month,
and it ran for 200ms each time, your charges would be calculated as follows:
What should you do next?
• Take just one API and turn it into a Lambda function.
• Build a mobile app using the Mobile SDK using Lambda as
your backend
AWS Lambda Presentation (Tech Talk DC)
• Great example of scaling a total of 57 lines of code including error handling to
16 million posts a day.
• Scrub to 26:00 to see the Zillow presentation
https://www.youtube.com/watch?v=ygHGPnAd0Uo
Zillow Use Case (cont’d)
Zillow Use Case (cont’d)
Zillow Use Case (cont’d)
Calling Lambda Functions (extra)
Call from mobile or web apps
- Wait for a response or send an event and continue
- AWS SDK, AWS Mobile, Rest API, CLI
Send events from S3, or SNS
- One event per Lambda invocation, 3 attempts
Process DynamoDB changes records as events:
- Ordered model with multiple records per event
- Unlimited retries (until data expires) or determined by your code
Writing Lambda Functions (extra)
• AWS SDK by default
• Imagemagick for NodeJS Lambdas
• Lambda handles the inbound traffic (no web server)
• Scheduled Functions! (uses cron syntax)
• Allows versioning via a publish API so you can create immutable contracts with your
clients, and you can version via S3
• (Versioning happens via the ARN format FunctionName:ARN or FunctionName:
$LATEST)
• You can alias the ARN, allows for each rollbacks by quickly associating an alias with a
different ARN. You can also version via the API in API Gateway by assigning the
resource to a different Lambda Function.
Stateless
• Use s3, DynamoDB, or any internet based storage to persist data.
• Call other API’s from your Lambda function, or other Lambdas.
• Uses processes, threads, sockets, i/o for file writing (ephemeral) etc…
• You can add your own libraries, no restrictions
Send events from S3, or SNS
- One event per Lambda invocation, 3 attempts
Process DynamoDB changes records as events:
- Ordered model with multiple records per event
- Unlimited retries (until data expires) or determined by your code
1 of 33

Recommended

AWS Lambda - Event Driven Event-driven Code in the Cloud by
AWS Lambda - Event Driven Event-driven Code in the CloudAWS Lambda - Event Driven Event-driven Code in the Cloud
AWS Lambda - Event Driven Event-driven Code in the CloudAmazon Web Services
1.9K views36 slides
Lambda and serverless - DevOps North East Jan 2017 by
Lambda and serverless - DevOps North East Jan 2017Lambda and serverless - DevOps North East Jan 2017
Lambda and serverless - DevOps North East Jan 2017Mike Shutlar
317 views34 slides
(CMP407) Lambda as Cron: Scheduling Invocations in AWS Lambda by
(CMP407) Lambda as Cron: Scheduling Invocations in AWS Lambda(CMP407) Lambda as Cron: Scheduling Invocations in AWS Lambda
(CMP407) Lambda as Cron: Scheduling Invocations in AWS LambdaAmazon Web Services
17.9K views34 slides
AWS Lambda: Event-driven Code in the Cloud by
AWS Lambda: Event-driven Code in the CloudAWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the CloudAmazon Web Services
5K views29 slides
AWS October Webinar Series - AWS Lambda Best Practices: Python, Scheduled Job... by
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...Amazon Web Services
8.1K views39 slides
AWS Lambda: Event-driven Code in the Cloud by
AWS Lambda: Event-driven Code in the CloudAWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the CloudAmazon Web Services
5.1K views29 slides

More Related Content

What's hot

AWS Lambda: Event-Driven Code in the Cloud by
AWS Lambda: Event-Driven Code in the CloudAWS Lambda: Event-Driven Code in the Cloud
AWS Lambda: Event-Driven Code in the CloudAmazon Web Services
4.4K views30 slides
(CMP403) AWS Lambda: Simplifying Big Data Workloads by
(CMP403) AWS Lambda: Simplifying Big Data Workloads(CMP403) AWS Lambda: Simplifying Big Data Workloads
(CMP403) AWS Lambda: Simplifying Big Data WorkloadsAmazon Web Services
5.8K views33 slides
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts by
Skillenza Build with Serverless Challenge -  Advanced Serverless ConceptsSkillenza Build with Serverless Challenge -  Advanced Serverless Concepts
Skillenza Build with Serverless Challenge - Advanced Serverless ConceptsDhaval Nagar
96 views40 slides
Real Time Data Processing Using AWS Lambda - DevDay Los Angeles 2017 by
Real Time Data Processing Using AWS Lambda - DevDay Los Angeles 2017Real Time Data Processing Using AWS Lambda - DevDay Los Angeles 2017
Real Time Data Processing Using AWS Lambda - DevDay Los Angeles 2017Amazon Web Services
1.1K views41 slides
Real-time Data Processing Using AWS Lambda by
Real-time Data Processing Using AWS LambdaReal-time Data Processing Using AWS Lambda
Real-time Data Processing Using AWS LambdaAmazon Web Services
3.3K views40 slides
A Walk in the Cloud with AWS Lambda by
A Walk in the Cloud with AWS LambdaA Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS LambdaAmazon Web Services
10.3K views41 slides

What's hot(20)

(CMP403) AWS Lambda: Simplifying Big Data Workloads by Amazon Web Services
(CMP403) AWS Lambda: Simplifying Big Data Workloads(CMP403) AWS Lambda: Simplifying Big Data Workloads
(CMP403) AWS Lambda: Simplifying Big Data Workloads
Amazon Web Services5.8K views
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts by Dhaval Nagar
Skillenza Build with Serverless Challenge -  Advanced Serverless ConceptsSkillenza Build with Serverless Challenge -  Advanced Serverless Concepts
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
Dhaval Nagar96 views
Real Time Data Processing Using AWS Lambda - DevDay Los Angeles 2017 by Amazon Web Services
Real Time Data Processing Using AWS Lambda - DevDay Los Angeles 2017Real Time Data Processing Using AWS Lambda - DevDay Los Angeles 2017
Real Time Data Processing Using AWS Lambda - DevDay Los Angeles 2017
Amazon Web Services1.1K views
Getting Started with Serverless Architectures by Amazon Web Services
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
Amazon Web Services1.9K views
AWS Lambda and the Serverless Cloud -Pop-up Loft by Amazon Web Services
AWS Lambda and the Serverless Cloud -Pop-up LoftAWS Lambda and the Serverless Cloud -Pop-up Loft
AWS Lambda and the Serverless Cloud -Pop-up Loft
Getting Started with Serverless Architectures by Amazon Web Services
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
Amazon Web Services9.3K views
Serverless presentation by jasonsich
Serverless presentationServerless presentation
Serverless presentation
jasonsich1.7K views
AWS Lambda and Serverless framework: lessons learned while building a serverl... by Luciano Mammino
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 Mammino2.1K views
AWS Lambda from the Trenches by Yan Cui
AWS Lambda from the TrenchesAWS Lambda from the Trenches
AWS Lambda from the Trenches
Yan Cui5.8K views
Increase Speed and Agility with Amazon Web Services by Amazon Web Services
Increase Speed and Agility with Amazon Web ServicesIncrease Speed and Agility with Amazon Web Services
Increase Speed and Agility with Amazon Web Services
Amazon Web Services1.8K views
JavaZone 2017 : Building a smart security camera with raspberry pi zero, java... by Mark West
JavaZone 2017 : Building a smart security camera with raspberry pi zero, java...JavaZone 2017 : Building a smart security camera with raspberry pi zero, java...
JavaZone 2017 : Building a smart security camera with raspberry pi zero, java...
Mark West632 views
AWS March 2016 Webinar Series Getting Started with Serverless Architectures by Amazon Web Services
AWS March 2016 Webinar Series   Getting Started with Serverless ArchitecturesAWS March 2016 Webinar Series   Getting Started with Serverless Architectures
AWS March 2016 Webinar Series Getting Started with Serverless Architectures
Amazon Web Services2.2K views

Similar to AWS Lambda Presentation (Tech Talk DC)

Getting Started with AWS Lambda and the Serverless Cloud by
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 CloudAmazon Web Services
3.1K views43 slides
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud by
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless CloudAWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless CloudAmazon Web Services
353 views55 slides
Getting Started with Serverless Architectures | AWS Public Sector Summit 2016 by
Getting Started with Serverless Architectures | AWS Public Sector Summit 2016Getting Started with Serverless Architectures | AWS Public Sector Summit 2016
Getting Started with Serverless Architectures | AWS Public Sector Summit 2016Amazon Web Services
1.1K views37 slides
AWS Lambda and Serverless Cloud by
AWS Lambda and Serverless CloudAWS Lambda and Serverless Cloud
AWS Lambda and Serverless CloudAmazon Web Services
7.6K views39 slides
Serverlessusecase workshop feb3_v2 by
Serverlessusecase workshop feb3_v2Serverlessusecase workshop feb3_v2
Serverlessusecase workshop feb3_v2kartraj
152 views31 slides
Getting Started with AWS Lambda and the Serverless Cloud by
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 CloudAmazon Web Services
2.8K views55 slides

Similar to AWS Lambda Presentation (Tech Talk DC)(20)

Getting Started with AWS Lambda and the Serverless Cloud by Amazon Web Services
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
Amazon Web Services3.1K views
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud by Amazon Web Services
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless CloudAWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with Serverless Architectures | AWS Public Sector Summit 2016 by Amazon Web Services
Getting Started with Serverless Architectures | AWS Public Sector Summit 2016Getting Started with Serverless Architectures | AWS Public Sector Summit 2016
Getting Started with Serverless Architectures | AWS Public Sector Summit 2016
Amazon Web Services1.1K views
Serverlessusecase workshop feb3_v2 by kartraj
Serverlessusecase workshop feb3_v2Serverlessusecase workshop feb3_v2
Serverlessusecase workshop feb3_v2
kartraj152 views
Getting Started with AWS Lambda and the Serverless Cloud by Amazon Web Services
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
Amazon Web Services2.8K views
AWS March 2016 Webinar Series - AWS IoT Real Time Stream Processing with AWS ... by Amazon Web Services
AWS March 2016 Webinar Series - AWS IoT Real Time Stream Processing with AWS ...AWS March 2016 Webinar Series - AWS IoT Real Time Stream Processing with AWS ...
AWS March 2016 Webinar Series - AWS IoT Real Time Stream Processing with AWS ...
Amazon Web Services4.9K views
Getting Started with AWS Lambda & Serverless Cloud by Ian Massingham
Getting Started with AWS Lambda & Serverless CloudGetting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless Cloud
Ian Massingham459 views
AWS for Java Developers workshop by Rory Preddy
AWS for Java Developers workshopAWS for Java Developers workshop
AWS for Java Developers workshop
Rory Preddy180 views
Serverless Meetup - Event Sourcing by Luca Bianchi
Serverless Meetup - Event SourcingServerless Meetup - Event Sourcing
Serverless Meetup - Event Sourcing
Luca Bianchi507 views
AWS for the Java Developer by Rory Preddy
AWS for the Java DeveloperAWS for the Java Developer
AWS for the Java Developer
Rory Preddy908 views
2016-06 - Design your api management strategy - AWS - Microservices on AWS by SmartWave
2016-06 - Design your api management strategy - AWS - Microservices on AWS2016-06 - Design your api management strategy - AWS - Microservices on AWS
2016-06 - Design your api management strategy - AWS - Microservices on AWS
SmartWave195 views
使用 AWS 無伺服器運算服務打造您的第一個語音助理 by Amazon Web Services
使用 AWS 無伺服器運算服務打造您的第一個語音助理使用 AWS 無伺服器運算服務打造您的第一個語音助理
使用 AWS 無伺服器運算服務打造您的第一個語音助理
Amazon Web Services1.7K views
Serverless architectures on aws by Paolo latella
Serverless architectures on awsServerless architectures on aws
Serverless architectures on aws
Paolo latella911 views
Serverless Architectures on AWS Lambda by Serhat Can
Serverless Architectures on AWS LambdaServerless Architectures on AWS Lambda
Serverless Architectures on AWS Lambda
Serhat Can1.5K views
Getting Started with AWS Lambda and the Serverless Cloud by Amazon Web Services
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
Amazon Web Services1.9K views
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your... by Amazon Web Services
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...
AWS and Serverless with Alexa by Rory Preddy
AWS and Serverless with AlexaAWS and Serverless with Alexa
AWS and Serverless with Alexa
Rory Preddy511 views
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit... by Amazon Web Services
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Amazon Web Services1.6K views

Recently uploaded

AI + Memoori = AIM by
AI + Memoori = AIMAI + Memoori = AIM
AI + Memoori = AIMMemoori
14 views9 slides
Choosing the Right Flutter App Development Company by
Choosing the Right Flutter App Development CompanyChoosing the Right Flutter App Development Company
Choosing the Right Flutter App Development CompanyFicode Technologies
13 views9 slides
Mobile Core Solutions & Successful Cases.pdf by
Mobile Core Solutions & Successful Cases.pdfMobile Core Solutions & Successful Cases.pdf
Mobile Core Solutions & Successful Cases.pdfIPLOOK Networks
14 views7 slides
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」 by
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」PC Cluster Consortium
25 views12 slides
Qualifying SaaS, IaaS.pptx by
Qualifying SaaS, IaaS.pptxQualifying SaaS, IaaS.pptx
Qualifying SaaS, IaaS.pptxSachin Bhandari
1.1K views8 slides
The Role of Patterns in the Era of Large Language Models by
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language ModelsYunyao Li
91 views65 slides

Recently uploaded(20)

AI + Memoori = AIM by Memoori
AI + Memoori = AIMAI + Memoori = AIM
AI + Memoori = AIM
Memoori14 views
Mobile Core Solutions & Successful Cases.pdf by IPLOOK Networks
Mobile Core Solutions & Successful Cases.pdfMobile Core Solutions & Successful Cases.pdf
Mobile Core Solutions & Successful Cases.pdf
IPLOOK Networks14 views
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」 by PC Cluster Consortium
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」
PCCC23:日本AMD株式会社 テーマ2「AMD EPYC™ プロセッサーを用いたAIソリューション」
The Role of Patterns in the Era of Large Language Models by Yunyao Li
The Role of Patterns in the Era of Large Language ModelsThe Role of Patterns in the Era of Large Language Models
The Role of Patterns in the Era of Large Language Models
Yunyao Li91 views
What is Authentication Active Directory_.pptx by HeenaMehta35
What is Authentication Active Directory_.pptxWhat is Authentication Active Directory_.pptx
What is Authentication Active Directory_.pptx
HeenaMehta3515 views
LLMs in Production: Tooling, Process, and Team Structure by Aggregage
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team Structure
Aggregage57 views
"Node.js Development in 2024: trends and tools", Nikita Galkin by Fwdays
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin
Fwdays33 views
This talk was not generated with ChatGPT: how AI is changing science by Elena Simperl
This talk was not generated with ChatGPT: how AI is changing scienceThis talk was not generated with ChatGPT: how AI is changing science
This talk was not generated with ChatGPT: how AI is changing science
Elena Simperl32 views
Initiating and Advancing Your Strategic GIS Governance Strategy by Safe Software
Initiating and Advancing Your Strategic GIS Governance StrategyInitiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance Strategy
Safe Software184 views
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
Measurecamp Brussels - Synthetic data.pdf by Human37
Measurecamp Brussels - Synthetic data.pdfMeasurecamp Brussels - Synthetic data.pdf
Measurecamp Brussels - Synthetic data.pdf
Human37 26 views
Future of AR - Facebook Presentation by Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty65 views
"Surviving highload with Node.js", Andrii Shumada by Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays58 views

AWS Lambda Presentation (Tech Talk DC)

  • 1. Who Am I ? By day: Technical Program Manager • National Rural Electric Cooperative Association • Large 40M+ Angular, Backbone.JS, .Net WebApi • application By night JavaScript Extraordinaire Co-Founder & Chief Engineer for Hoozip.com • Angular • AWS S3 • AWS Lambda • AWS Api Gateway • AWS EC2 @javascriptbully
  • 2. • Mongo • Express • Angular • NodeJS • AWS • NodeJS • Angular • Lambda @javascriptbully “Time to get Mean!” ? Who Am I ?
  • 4. Event-Driven Compute • As data enters your cloud infrastructure Lambda makes it extremely easy to transform that data by applying your function to the data based on events you define. • Examples include data transformation, image transformation, large scale data analysis. For example, run transformation functions whenever a DynamoDB table is loaded. • Ability to scale horizontally across large scale work loads and dynamically then instantly shrink back once the work is complete. • 100 concurrent executions • 1,000 invokes per second Quickly build mobile Backends • AWS mobile SDKs
  • 5. Lambda offering overview • Runs code in response to events • Object uploads to Amazon S3 • Updates to Amazon DynamoDB via Streams • Data in Amazon Kinesis Streams • In app activity • Lambda handles all capacity, scaling, patching and infrastructure administration • Lambda only runs your code when triggered so you don’t have to pay for unused capacity • Provides realtime metrics and logs to Amazon CloudWatch • Low cost, No upfront costs • Code is charged in measurements of 100ms increments • Python, Java, NodeJs • Lambda Function (Micro service architecture) • Prebuilt examples • Built in support for AWS SDK • AWS Free Tier you can try Lambda for free • Security is baked in
  • 6. Lambda offering overview (cont’d) AWS Lambda supports the following runtime versions • Node.js: v0.10.36 • Java: Java 8 • Python: Python 2.7 If you author your Lambda function code in Node.js, the following libraries are available in the AWS Lambda execution environment so you don't need to include them: • ImageMagick: Installed with default settings. For versioning information, see imagemagick nodejs wrapper and ImageMagick native binary (search for "ImageMagick"). • AWS SDK: AWS SDK for JavaScript version 2.2.32 If you author your Lambda function code in Python, the following libraries are available in the AWS Lambda execution environment so you don't need to include them: • AWS SDK for Python (Boto 3) version 1.2.3 There are no additional libraries available for Java.
  • 7. Hoozip Use Case • Want to send property reports on demand via SMS • Wanted to follow an event driven, micro service design • Scale our systems up or down when certain load metrics are hit • Send out notifications to owners of properties when their property is requested • Managing and reacting to all those events would require a complex infrastructure, so often we simply put them together in one controller action or use observers that run in the same processes as our applications. This makes the codebase more complex as parts start getting interwoven. • Most teams start pushing those tasks into background workers, but the infrastructure necessary for managing tasks this way is overhead too. Therefore, background workers are typically limited to the most important tasks. This is especially true when they don’t get automatically triggered by events, but need to be triggered through the codebase. Doing this adds another level of complexity to the code in order to understand which part triggers which event. • It lets you write small NodeJS functions that will be called with the event metadata from events triggered by various services or through your own code.
  • 8. Hoozip • Hoozip.com is a marketplace and software provider for real estate investors (rehabbers, wholesalers, lenders) to find, post, and curate real estate investment deals in an efficient way.
  • 9. What we normally would do • Size Provision Scale Servers • Estimate capacity • Run fault tolerance • Manage Operating System Updates • Apply Security Patches • Monitor for performance and availability • Lambda does the impedance matching for your event flow so you don’t have to worry about over or under provisioning as Lambda scales elastically
  • 10. call twilio post to ApiGateway call Lambda parse message fuzzy address geoCode address call property API call bitly API persist to DynamoDB generate message post back to twiliosend message How we did it… * As the API get’s busier, we’ll add a queueing / push notification mechanism via SQS & SNS
  • 11. TEXT YOUR DEAL ADDRESS TO HOOZIP! (202) 798-1333
  • 12. Hoozip Architecture • We serve our Angular app out of a S3 Bucket • We use CloudFront as our CDN for all static assets including the Angular App • Most of our services are separate stand alone projects and handled via Api Gateway and Lambda • We currently use DynamoDB for persisting and Postgres as our store for financial related actions and some GeoSpatial calculations. • When we can’t use Lambda (static IP addressing, computationally heavy work loads) we use EC2 with Node v4.0, Express, served via Node Forever and NodeMon
  • 14. What’s available while programming in Node? • Lambda Function Handler • Event Object • Context Object • ImageMagick available (Node.js) • Logging & Monitoring (CloudWatch & CloudTrail) • Exceptions • Ephemeral I/O operations while function is executing • Awesome! But the worst part: • Node v0.10.36 • http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html
  • 15. Code via the online code editor, or in your own IDE • Let’s build a simple API that goes out to Github, and get’s a user object. • Here’s our Lambda function:
  • 16. Testing your Lambda function locally • Easy to test your logic locally • Easy to turn this into an express module that you can then use to serve via an api somewhere else so you’re not bound to Lambda if you decide to move at a later date.
  • 17. Upload your code • Compress the items in you source folder. • Upload the zip file directly to your Lamda function via the console. • Better if you use a task manager like Gulp that will zip the file and upload it for you via the AWS SDK publish API • I prefer to use Gulp to zip my code, then upload to S3 so I have artifact versioning as well. I wrote another Lambda functions that listens for upload events on that bucket then imports the code into my Lambda function.
  • 18. Now let’s create an API in API Gateway that integrates with our Lambda Function
  • 19. Let’s setup our API to have a query string parameter called ‘name’ that we pass into our Lambda Function
  • 20. Next we map the data retrieved byApi Gateway to the Event object passed into our Lambda Function via the mapping template
  • 21. Let’s deploy our Api to a stage called ‘prod’! Staging allows you to create various versions of your Api for testing, different clients, etc…
  • 22. And we’re done! Instantly scalable to millions of users!
  • 23. Here’s my Lambda function that deploys other Lambda Functions • Event source for this Lambda function in my S3 bucket where I upload my Lambda zip files • Uses the AWS SDK which is already loaded into memory by AWS.
  • 24. Pricing Details • No hourly, daily, monthly minimums • No per device fees • Compute time is purchased in 100ms increments • 1M requests and 400,000 GB-s of compute every month for free • You only pay when you’re doing work, not when you’re idle. Requests You are charged for the total number of requests across all your functions. Lambda counts a request each time it starts executing in response to an event notification or invoke call, including test invokes from the console. • First 1 million requests per month are free • $0.20 per 1 million requests thereafter ($0.0000002 per request) Duration Duration is calculated from the time your code begins executing until it returns or otherwise terminates, rounded up to the nearest 100ms. The price depends on the amount of memory you allocate to your function. You are charged $0.00001667 for every GB-second used. Free Tier The Lambda free tier includes 1M free requests per month and 400,000 GB-seconds of compute time per month. The memory size you choose for your Lambda functions determines how long they can run in the free tier. The Lambda free tier does not automatically expire at the end of your 12 month AWS Free Tier term, but is available to both existing and new AWS customers indefinitely.
  • 25. Monthly compute charges The monthly compute price is $0.00001667 per GB-s and the free tier provides 400,000 GB-s. Total compute (seconds) = 30M * (0.2sec) = 6,000,000 seconds Total compute (GB-s) = 6,000,000 * 128MB/1024 = 750,000 GB-s Total Compute – Free tier compute = Monthly billable compute seconds 750,000 GB-s – 400,000 free tier GB-s = 350,000 GB-s Monthly compute charges = 350,000 * $0.00001667 = $5.83 Monthly request charges The monthly request price is $0.20 per 1 million requests and the free tier provides 1M requests per month. Total requests – Free tier request = Monthly billable requests 30M requests – 1M free tier requests = 29M Monthly billable requests Monthly request charges = 29M * $0.2/M = $5.80 Total compute charges Total charges = Compute charges + Request charges = $5.83 + $5.80 = $11.63 per month Pricing Example If you allocated 128MB of memory to your function, executed it 30 million times in one month, and it ran for 200ms each time, your charges would be calculated as follows:
  • 26. What should you do next? • Take just one API and turn it into a Lambda function. • Build a mobile app using the Mobile SDK using Lambda as your backend
  • 28. • Great example of scaling a total of 57 lines of code including error handling to 16 million posts a day. • Scrub to 26:00 to see the Zillow presentation https://www.youtube.com/watch?v=ygHGPnAd0Uo
  • 29. Zillow Use Case (cont’d)
  • 30. Zillow Use Case (cont’d)
  • 31. Zillow Use Case (cont’d)
  • 32. Calling Lambda Functions (extra) Call from mobile or web apps - Wait for a response or send an event and continue - AWS SDK, AWS Mobile, Rest API, CLI Send events from S3, or SNS - One event per Lambda invocation, 3 attempts Process DynamoDB changes records as events: - Ordered model with multiple records per event - Unlimited retries (until data expires) or determined by your code
  • 33. Writing Lambda Functions (extra) • AWS SDK by default • Imagemagick for NodeJS Lambdas • Lambda handles the inbound traffic (no web server) • Scheduled Functions! (uses cron syntax) • Allows versioning via a publish API so you can create immutable contracts with your clients, and you can version via S3 • (Versioning happens via the ARN format FunctionName:ARN or FunctionName: $LATEST) • You can alias the ARN, allows for each rollbacks by quickly associating an alias with a different ARN. You can also version via the API in API Gateway by assigning the resource to a different Lambda Function. Stateless • Use s3, DynamoDB, or any internet based storage to persist data. • Call other API’s from your Lambda function, or other Lambdas. • Uses processes, threads, sockets, i/o for file writing (ephemeral) etc… • You can add your own libraries, no restrictions Send events from S3, or SNS - One event per Lambda invocation, 3 attempts Process DynamoDB changes records as events: - Ordered model with multiple records per event - Unlimited retries (until data expires) or determined by your code