際際滷

際際滷Share a Scribd company logo
Building Serverless Apps
using AWS Lambda
Author: Liep Nguyen
Agenda
1. Serverless Architectures
2. Cons & Pros
3. What is AWS Lambda?
4. Building Application with AWS Lambda
5. AWS Lambdas use cases
6. Demo
Simple Problem
 You want to generate thumbnail images when they are uploaded to a
bucket
Solve the problem with a traditional
solution
Disadvantage
 Design provision and scale a bunch of servers
 Manage operation updates, apply security patches
 Monitor all the infrastructure for performance and availability
When having a large
number of images
Need more server instances to
handle uploaded images
Serverless Architectures
Function as a Service
(execute your custom code)
Backend as a Service
(third party services)
Serverless Architectures
Backend as a Service / BaaS
3rd party applications / services (in the cloud) that
your applications use to manage server-side logic
and state
Cloud accessible databases

Authentication services
AWS Cognito
Traditionally deploy server-side software
Host Instance (Container)
Application (Process) Operation
Operation
Operation
Function as a Service / FaaS
Host Instance (Container)
Application (Process) Operation
Operation
Operation
FaaS Platform
Function as a Service / FaaS
Operation
Operation
Operation
FaaS Platform
Function as a Service / FaaS
Operation
Operation
Operation
Operation
Each operation listens to specific event
Ephemeral Container
Function as a Service / FaaS
FaaS Platform
Operation
Operation
Operation
Operation
Function as a Service / FaaS
 Example: How FaaS works in AWS Lambda
Serverless Architectures - Examples
Example 1: The architecture of an ecommerce app
DatabaseClient App Server
The traditional architecture will look like this:
Serverless Architectures - Examples
Purchase
Database
Client
With a Serverless architecture, this may look like this:
Authentication
Service
API Gateway
Purchase Function
Search Function
Product
Database
1
2
4
5
3
Serverless Architectures - Benefits
Reduced Development Cost
Scaling CostsFunction as a Service / FaaS
Backend as a Service / BaaS
BaaS  Reduced Development Cost
APPLICATION BUSINESS LOGIC
DATA PROCESSING / MANAGEMENT

Users Databases PUB SUB Files
BACK-END
Serverless BaaS services are provided via
the use of custom SDKs and APIs, using
these such services reduces
development cost
Backend as a Service
FaaS  Scaling Costs
Horizontal scaling is completely automatic, elastic, and managed by the provider
Only pay for the compute that you need
FaaS  Scaling Costs
OCCASIONAL REQUESTS INCONSISTENT TRAFFIC
0
2
4
6
8
NumberofRequests
Minutes
Number of Requests
Number of Requests
0
100
200
300
NumberofRequests
Minutes
Number of Requests
Number of Requests Require more CPU
Mean CPU usage over an hour is 0.1%. The application traffic is bursty
Examples
Serverless Architectures  Drawbacks
Problems due to third-
party API system
 Vendor control
 Multitenancy
problems
 Vendor lock-in
 Security concerns
Lack of operational
tools
 Dependent on
vendors for
debugging and
monitoring tool
Architectural
complexity
 Decisions about how
the small function
should be
Implementation
drawbacks
 Integration testing
Serverless Apps is
hard
 Execution Duration
 Startup Latency
 Testing
Serverless FaaS - Implementations
Comparison
Feature AWS Lambda Google Cloud Azure Functions
Scalability & availability Automatic scaling Automatic scaling Automatic scaling
Supported languages JavaScript, Java, Python, C# Only JavaScript
C# and JavaScript (preview of F#,
Python, Batch, PHP, PowerShell)
Max concurrent functions 1000 invocations 400 invocations (but can be increased) No limit
Max function duration 300 seconds 540 seconds 5 minutes
Event-driven
S3, SNS, SES, DynamoDB, Kinesis,
CloudWatch, Cognito, API Gateway,
CodeCommit, etc.
Cloud Pub/Sub or Cloud Storage Object
Change Notifications
WebHook, GitHub WebHook, Queue,
Http, ServiceBus Queue, Service Bus
Topic, Timer triggers
Pricing
Invocations: 1M Invocations
for free (Free Tier), then $0.20/1M
Invocations
GB-s: 400,000 GB-s for free, then
$0.00001667 per GB-s
Invocations: 2M Invocations for free,
then $0.40/1M Invocations
GB-s: 400,000 GB-s for tree, then
$0.0000025 per GB-s
GHz-s: 200,000 for tree tire, then
$0.0000100 per GHz-s
Invocations: 1M Invocations
for free (Free Tier), then $0.20/1M
Invocations
GB-s: 400,000 GB-s for free, then
$0.000016 per GB-s
What is AWS Lambda?
An implementation of Serverless
Architecture
Provides FaaS container to run your
custom code in response to events.
Building Lambda Functions
Authoring code for
your Lambda
function
Uploading code
and creating
Lambda functions
Monitoring and
troubleshooting
Building Lambda Functions
Authoring code for your Lambda function
1. Language you choose to write your Lambda function code.
2. AWS Lambda runtime provides some of the libraries and you must upload any additional libraries that
you use.
Languages Tools and Options for Authoring Code More Information
Node.js  AWS Lambda console
 Visual Studio, with IDE plug-in
 The AWS Toolkit also creates the deployment package
 You can use the console if the languages you choose do not
require compilation, the code is saved in a single file, and it
does not depend on any libraries.
Java  Eclipse, with AWS Toolkit for Eclipse
C#  Visual Studio, with IDE plug-in
 .NET Core
Python  AWS Lambda console
Building Lambda Functions
Deploying Code and Creating a Lambda Function
1. Creating a Deployment Package
2. Creating a Lambda Function
3. Uploading a Deployment Package
4. Testing a Lambda Function
Building Lambda Functions
Monitoring and Troubleshooting
1. Sign in to the AWS Management Console and open the AWS Lambda console
2. On the Functions page, choose the function name and then choose the Monitoring tab
Building applications with AWS Lambda
 Core Components of AWS Lambda:
Event Sources Lambda Functions
 An event source is the AWS service or custom application that publishes events
 A Lambda function is the custom code that processes the events
Building applications with AWS Lambda
 Event Source Mapping
AWS services
Custom application
Regular AWS services
(All other AWS services do not use stream event source)
Stream-based services
(Amazon Kinesis Streams and Amazon DynamoDB Streams)
Event sources
Building applications with AWS Lambda
 Event Source Mapping for AWS Services
o Example  Amazon S3 Pushes Events and Invokes a Lambda Function
 Need to grant the event source the necessary
permissions using a resource-based policy
Building applications with AWS Lambda
 Event Source Mapping for AWS Stream-based Services
o Example  AWS Lambda Pulls Events from an Amazon Kinesis Stream and
Invokes a Lambda Function
 AWS Lambda needs your permission to
poll the stream and read records
Building applications with AWS Lambda
 Event Source Mapping for Custom Applications
o Example  Custom Application Publishes Events and Invokes a Lambda
Function
 No pre-configuration required
 Dont have to set up event source mapping
 The event source use the AWS Lambda
Invoke API
 Must allow cross-account permissions in
the permissions policy associated with the
Lambda function in case the application
and Lambda function are owned by
difference accounts
What can you build with AWS Lambda?
 Data Processing
o Real-time File Processing
o Real-time Stream Processing
o Extract, Transform, Load
 Backends
o IoT Backends
o Mobile Backends
o Web Applications
What can you build with AWS Lambda?
 Data Processing > Real-time File Processing
What can you build with AWS Lambda?
 Data Processing > Real-time Stream Processing
What can you build with AWS Lambda?
 Data Processing > Extract, Transform, Load
What can you build with AWS Lambda?
 Backends > IoT Backends
What can you build with AWS Lambda?
 Backends > Mobile Backends
What can you build with AWS Lambda?
 Backends > Web Applications
DEMO
Demo 1
 Create a Lambda function to generate thumbnail images when there are photos
uploaded to a S3 Bucket
Demo 2
 Build a Severless Web API by using AWS Lambda
client Amazon API Gateway Lambda function
References
 AWS Lambda Developer Guide: http://docs.aws.amazon.com/lambda/latest/dg
 Introduction to AWS Lambda - Serverless Compute on Amazon Web Services:
https://www.youtube.com/watch?v=eOBq__h4OJ4
 AWS re:Invent 2014 | (MBL202) NEW LAUNCH: Getting Started with AWS
Lambda: https://www.youtube.com/watch?v=UFj27laTWQA
 Technical Introduction to AWS Lambda - Serverless Compute on AWS:
https://www.youtube.com/watch?v=QzipnZzAQEk
 Serverless Architectures - Martin Fowler
Q & A
THANKS FOR YOUR LISTENING

More Related Content

Similar to Building serverless app_using_aws_lambda_b4usolution (8)

Building serverless backends - Tech talk 5 May 2017
Building serverless backends - Tech talk 5 May 2017Building serverless backends - Tech talk 5 May 2017
Building serverless backends - Tech talk 5 May 2017
ARDC
Stephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
Stephen Liedig: Building Serverless Backends with AWS Lambda and API GatewayStephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
Stephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
Steve Androulakis
Getting Started with AWS Lambda and Serverless Computing
Getting Started with AWS Lambda and Serverless ComputingGetting Started with AWS Lambda and Serverless Computing
Getting Started with AWS Lambda and Serverless Computing
Kristana Kane
2016-06 - Design your api management strategy - AWS - Microservices on AWS
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
SmartWave
AWS and Serverless with Alexa
AWS and Serverless with AlexaAWS and Serverless with Alexa
AWS and Serverless with Alexa
Rory Preddy
Getting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless CloudGetting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless Cloud
Ian Massingham
What is Serverless Computing?
What is Serverless Computing?What is Serverless Computing?
What is Serverless Computing?
AIMDek Technologies
Developing serverless applications with .NET on AWS
Developing serverless applications with .NET on AWSDeveloping serverless applications with .NET on AWS
Developing serverless applications with .NET on AWS
Woody Pewitt
Building serverless backends - Tech talk 5 May 2017
Building serverless backends - Tech talk 5 May 2017Building serverless backends - Tech talk 5 May 2017
Building serverless backends - Tech talk 5 May 2017
ARDC
Stephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
Stephen Liedig: Building Serverless Backends with AWS Lambda and API GatewayStephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
Stephen Liedig: Building Serverless Backends with AWS Lambda and API Gateway
Steve Androulakis
Getting Started with AWS Lambda and Serverless Computing
Getting Started with AWS Lambda and Serverless ComputingGetting Started with AWS Lambda and Serverless Computing
Getting Started with AWS Lambda and Serverless Computing
Kristana Kane
2016-06 - Design your api management strategy - AWS - Microservices on AWS
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
SmartWave
AWS and Serverless with Alexa
AWS and Serverless with AlexaAWS and Serverless with Alexa
AWS and Serverless with Alexa
Rory Preddy
Getting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless CloudGetting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless Cloud
Ian Massingham
Developing serverless applications with .NET on AWS
Developing serverless applications with .NET on AWSDeveloping serverless applications with .NET on AWS
Developing serverless applications with .NET on AWS
Woody Pewitt

Recently uploaded (20)

CEE Software Development M&A Report 2025
CEE Software Development M&A Report 2025CEE Software Development M&A Report 2025
CEE Software Development M&A Report 2025
Yevgen Sysoyev
From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...
From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...
From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...
Pavel Shukhman
Codequiry: A Code Similarity Checker Every Developer Should Know
Codequiry: A Code Similarity Checker Every Developer Should KnowCodequiry: A Code Similarity Checker Every Developer Should Know
Codequiry: A Code Similarity Checker Every Developer Should Know
Code Quiry
AC3-SCRUM-Agile concepts in an enterprise environment
AC3-SCRUM-Agile concepts in an enterprise environmentAC3-SCRUM-Agile concepts in an enterprise environment
AC3-SCRUM-Agile concepts in an enterprise environment
Dennis Van Aelst
Meet, Greet, and Explore Agentic AI with UiPath Scotland
Meet, Greet, and Explore Agentic AI with UiPath ScotlandMeet, Greet, and Explore Agentic AI with UiPath Scotland
Meet, Greet, and Explore Agentic AI with UiPath Scotland
UiPathCommunity
Transactional Outbox & Inbox Patterns.pptx
Transactional Outbox & Inbox Patterns.pptxTransactional Outbox & Inbox Patterns.pptx
Transactional Outbox & Inbox Patterns.pptx
Maysam Mousa
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Buwaneka De Silva
Human Centered Design By Gnanasambandham
Human Centered Design By GnanasambandhamHuman Centered Design By Gnanasambandham
Human Centered Design By Gnanasambandham
Gnanasambandham Anbazhagan CSP, CSM, CSPO
Introduction to Generative AI refers to a subset of artificial intelligence
Introduction to Generative AI refers to a subset of artificial intelligenceIntroduction to Generative AI refers to a subset of artificial intelligence
Introduction to Generative AI refers to a subset of artificial intelligence
Kongu Engineering College, Perundurai, Erode
AI in SEO Marketing Presentation (BY MetaSense Marketing)
AI in SEO Marketing Presentation (BY MetaSense Marketing)AI in SEO Marketing Presentation (BY MetaSense Marketing)
AI in SEO Marketing Presentation (BY MetaSense Marketing)
MetaSenseMarketing
CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...
CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...
CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...
DanBrown980551
Threat Modeling a Batch Job System - AWS Security Community Day
Threat Modeling a Batch Job System - AWS Security Community DayThreat Modeling a Batch Job System - AWS Security Community Day
Threat Modeling a Batch Job System - AWS Security Community Day
Teri Radichel
MariaDB Berlin Roadshow 際際滷s - 8 April 2025
MariaDB Berlin Roadshow 際際滷s - 8 April 2025MariaDB Berlin Roadshow 際際滷s - 8 April 2025
MariaDB Berlin Roadshow 際際滷s - 8 April 2025
MariaDB plc
Ricardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno - A Structural CAD TechnicianRicardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno
Artificial Neural Networks, basics, its variations and examples
Artificial Neural Networks, basics, its variations and examplesArtificial Neural Networks, basics, its variations and examples
Artificial Neural Networks, basics, its variations and examples
anandsimple
Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...
Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...
Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...
davidandersonofficia
Commit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with KubescapeCommit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with Kubescape
Alfredo Garc鱈a Lavilla
Leadership in the AI Era: The Reinvention of Human-Centered Leadership by Bor...
Leadership in the AI Era: The Reinvention of Human-Centered Leadership by Bor...Leadership in the AI Era: The Reinvention of Human-Centered Leadership by Bor...
Leadership in the AI Era: The Reinvention of Human-Centered Leadership by Bor...
Agile ME
BrightonSEO April 2025 - hreflang XML E-Commerce - Nick Samuel.pdf
BrightonSEO April 2025 - hreflang XML E-Commerce - Nick Samuel.pdfBrightonSEO April 2025 - hreflang XML E-Commerce - Nick Samuel.pdf
BrightonSEO April 2025 - hreflang XML E-Commerce - Nick Samuel.pdf
Nick Samuel
FutureProofing the Nordic Economy with GenAI
FutureProofing the Nordic Economy with GenAIFutureProofing the Nordic Economy with GenAI
FutureProofing the Nordic Economy with GenAI
Pete Nieminen
CEE Software Development M&A Report 2025
CEE Software Development M&A Report 2025CEE Software Development M&A Report 2025
CEE Software Development M&A Report 2025
Yevgen Sysoyev
From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...
From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...
From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...
Pavel Shukhman
Codequiry: A Code Similarity Checker Every Developer Should Know
Codequiry: A Code Similarity Checker Every Developer Should KnowCodequiry: A Code Similarity Checker Every Developer Should Know
Codequiry: A Code Similarity Checker Every Developer Should Know
Code Quiry
AC3-SCRUM-Agile concepts in an enterprise environment
AC3-SCRUM-Agile concepts in an enterprise environmentAC3-SCRUM-Agile concepts in an enterprise environment
AC3-SCRUM-Agile concepts in an enterprise environment
Dennis Van Aelst
Meet, Greet, and Explore Agentic AI with UiPath Scotland
Meet, Greet, and Explore Agentic AI with UiPath ScotlandMeet, Greet, and Explore Agentic AI with UiPath Scotland
Meet, Greet, and Explore Agentic AI with UiPath Scotland
UiPathCommunity
Transactional Outbox & Inbox Patterns.pptx
Transactional Outbox & Inbox Patterns.pptxTransactional Outbox & Inbox Patterns.pptx
Transactional Outbox & Inbox Patterns.pptx
Maysam Mousa
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Buwaneka De Silva
AI in SEO Marketing Presentation (BY MetaSense Marketing)
AI in SEO Marketing Presentation (BY MetaSense Marketing)AI in SEO Marketing Presentation (BY MetaSense Marketing)
AI in SEO Marketing Presentation (BY MetaSense Marketing)
MetaSenseMarketing
CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...
CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...
CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...
DanBrown980551
Threat Modeling a Batch Job System - AWS Security Community Day
Threat Modeling a Batch Job System - AWS Security Community DayThreat Modeling a Batch Job System - AWS Security Community Day
Threat Modeling a Batch Job System - AWS Security Community Day
Teri Radichel
MariaDB Berlin Roadshow 際際滷s - 8 April 2025
MariaDB Berlin Roadshow 際際滷s - 8 April 2025MariaDB Berlin Roadshow 際際滷s - 8 April 2025
MariaDB Berlin Roadshow 際際滷s - 8 April 2025
MariaDB plc
Ricardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno - A Structural CAD TechnicianRicardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno
Artificial Neural Networks, basics, its variations and examples
Artificial Neural Networks, basics, its variations and examplesArtificial Neural Networks, basics, its variations and examples
Artificial Neural Networks, basics, its variations and examples
anandsimple
Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...
Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...
Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...
davidandersonofficia
Commit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with KubescapeCommit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with Kubescape
Alfredo Garc鱈a Lavilla
Leadership in the AI Era: The Reinvention of Human-Centered Leadership by Bor...
Leadership in the AI Era: The Reinvention of Human-Centered Leadership by Bor...Leadership in the AI Era: The Reinvention of Human-Centered Leadership by Bor...
Leadership in the AI Era: The Reinvention of Human-Centered Leadership by Bor...
Agile ME
BrightonSEO April 2025 - hreflang XML E-Commerce - Nick Samuel.pdf
BrightonSEO April 2025 - hreflang XML E-Commerce - Nick Samuel.pdfBrightonSEO April 2025 - hreflang XML E-Commerce - Nick Samuel.pdf
BrightonSEO April 2025 - hreflang XML E-Commerce - Nick Samuel.pdf
Nick Samuel
FutureProofing the Nordic Economy with GenAI
FutureProofing the Nordic Economy with GenAIFutureProofing the Nordic Economy with GenAI
FutureProofing the Nordic Economy with GenAI
Pete Nieminen

Building serverless app_using_aws_lambda_b4usolution

  • 1. Building Serverless Apps using AWS Lambda Author: Liep Nguyen
  • 2. Agenda 1. Serverless Architectures 2. Cons & Pros 3. What is AWS Lambda? 4. Building Application with AWS Lambda 5. AWS Lambdas use cases 6. Demo
  • 3. Simple Problem You want to generate thumbnail images when they are uploaded to a bucket
  • 4. Solve the problem with a traditional solution
  • 5. Disadvantage Design provision and scale a bunch of servers Manage operation updates, apply security patches Monitor all the infrastructure for performance and availability When having a large number of images Need more server instances to handle uploaded images
  • 6. Serverless Architectures Function as a Service (execute your custom code) Backend as a Service (third party services) Serverless Architectures
  • 7. Backend as a Service / BaaS 3rd party applications / services (in the cloud) that your applications use to manage server-side logic and state Cloud accessible databases Authentication services AWS Cognito
  • 8. Traditionally deploy server-side software Host Instance (Container) Application (Process) Operation Operation Operation
  • 9. Function as a Service / FaaS Host Instance (Container) Application (Process) Operation Operation Operation
  • 10. FaaS Platform Function as a Service / FaaS Operation Operation Operation
  • 11. FaaS Platform Function as a Service / FaaS Operation Operation Operation Operation Each operation listens to specific event
  • 12. Ephemeral Container Function as a Service / FaaS FaaS Platform Operation Operation Operation Operation
  • 13. Function as a Service / FaaS Example: How FaaS works in AWS Lambda
  • 14. Serverless Architectures - Examples Example 1: The architecture of an ecommerce app DatabaseClient App Server The traditional architecture will look like this:
  • 15. Serverless Architectures - Examples Purchase Database Client With a Serverless architecture, this may look like this: Authentication Service API Gateway Purchase Function Search Function Product Database 1 2 4 5 3
  • 16. Serverless Architectures - Benefits Reduced Development Cost Scaling CostsFunction as a Service / FaaS Backend as a Service / BaaS
  • 17. BaaS Reduced Development Cost APPLICATION BUSINESS LOGIC DATA PROCESSING / MANAGEMENT Users Databases PUB SUB Files BACK-END Serverless BaaS services are provided via the use of custom SDKs and APIs, using these such services reduces development cost Backend as a Service
  • 18. FaaS Scaling Costs Horizontal scaling is completely automatic, elastic, and managed by the provider Only pay for the compute that you need
  • 19. FaaS Scaling Costs OCCASIONAL REQUESTS INCONSISTENT TRAFFIC 0 2 4 6 8 NumberofRequests Minutes Number of Requests Number of Requests 0 100 200 300 NumberofRequests Minutes Number of Requests Number of Requests Require more CPU Mean CPU usage over an hour is 0.1%. The application traffic is bursty Examples
  • 20. Serverless Architectures Drawbacks Problems due to third- party API system Vendor control Multitenancy problems Vendor lock-in Security concerns Lack of operational tools Dependent on vendors for debugging and monitoring tool Architectural complexity Decisions about how the small function should be Implementation drawbacks Integration testing Serverless Apps is hard Execution Duration Startup Latency Testing
  • 21. Serverless FaaS - Implementations
  • 22. Comparison Feature AWS Lambda Google Cloud Azure Functions Scalability & availability Automatic scaling Automatic scaling Automatic scaling Supported languages JavaScript, Java, Python, C# Only JavaScript C# and JavaScript (preview of F#, Python, Batch, PHP, PowerShell) Max concurrent functions 1000 invocations 400 invocations (but can be increased) No limit Max function duration 300 seconds 540 seconds 5 minutes Event-driven S3, SNS, SES, DynamoDB, Kinesis, CloudWatch, Cognito, API Gateway, CodeCommit, etc. Cloud Pub/Sub or Cloud Storage Object Change Notifications WebHook, GitHub WebHook, Queue, Http, ServiceBus Queue, Service Bus Topic, Timer triggers Pricing Invocations: 1M Invocations for free (Free Tier), then $0.20/1M Invocations GB-s: 400,000 GB-s for free, then $0.00001667 per GB-s Invocations: 2M Invocations for free, then $0.40/1M Invocations GB-s: 400,000 GB-s for tree, then $0.0000025 per GB-s GHz-s: 200,000 for tree tire, then $0.0000100 per GHz-s Invocations: 1M Invocations for free (Free Tier), then $0.20/1M Invocations GB-s: 400,000 GB-s for free, then $0.000016 per GB-s
  • 23. What is AWS Lambda? An implementation of Serverless Architecture Provides FaaS container to run your custom code in response to events.
  • 24. Building Lambda Functions Authoring code for your Lambda function Uploading code and creating Lambda functions Monitoring and troubleshooting
  • 25. Building Lambda Functions Authoring code for your Lambda function 1. Language you choose to write your Lambda function code. 2. AWS Lambda runtime provides some of the libraries and you must upload any additional libraries that you use. Languages Tools and Options for Authoring Code More Information Node.js AWS Lambda console Visual Studio, with IDE plug-in The AWS Toolkit also creates the deployment package You can use the console if the languages you choose do not require compilation, the code is saved in a single file, and it does not depend on any libraries. Java Eclipse, with AWS Toolkit for Eclipse C# Visual Studio, with IDE plug-in .NET Core Python AWS Lambda console
  • 26. Building Lambda Functions Deploying Code and Creating a Lambda Function 1. Creating a Deployment Package 2. Creating a Lambda Function 3. Uploading a Deployment Package 4. Testing a Lambda Function
  • 27. Building Lambda Functions Monitoring and Troubleshooting 1. Sign in to the AWS Management Console and open the AWS Lambda console 2. On the Functions page, choose the function name and then choose the Monitoring tab
  • 28. Building applications with AWS Lambda Core Components of AWS Lambda: Event Sources Lambda Functions An event source is the AWS service or custom application that publishes events A Lambda function is the custom code that processes the events
  • 29. Building applications with AWS Lambda Event Source Mapping AWS services Custom application Regular AWS services (All other AWS services do not use stream event source) Stream-based services (Amazon Kinesis Streams and Amazon DynamoDB Streams) Event sources
  • 30. Building applications with AWS Lambda Event Source Mapping for AWS Services o Example Amazon S3 Pushes Events and Invokes a Lambda Function Need to grant the event source the necessary permissions using a resource-based policy
  • 31. Building applications with AWS Lambda Event Source Mapping for AWS Stream-based Services o Example AWS Lambda Pulls Events from an Amazon Kinesis Stream and Invokes a Lambda Function AWS Lambda needs your permission to poll the stream and read records
  • 32. Building applications with AWS Lambda Event Source Mapping for Custom Applications o Example Custom Application Publishes Events and Invokes a Lambda Function No pre-configuration required Dont have to set up event source mapping The event source use the AWS Lambda Invoke API Must allow cross-account permissions in the permissions policy associated with the Lambda function in case the application and Lambda function are owned by difference accounts
  • 33. What can you build with AWS Lambda? Data Processing o Real-time File Processing o Real-time Stream Processing o Extract, Transform, Load Backends o IoT Backends o Mobile Backends o Web Applications
  • 34. What can you build with AWS Lambda? Data Processing > Real-time File Processing
  • 35. What can you build with AWS Lambda? Data Processing > Real-time Stream Processing
  • 36. What can you build with AWS Lambda? Data Processing > Extract, Transform, Load
  • 37. What can you build with AWS Lambda? Backends > IoT Backends
  • 38. What can you build with AWS Lambda? Backends > Mobile Backends
  • 39. What can you build with AWS Lambda? Backends > Web Applications
  • 40. DEMO
  • 41. Demo 1 Create a Lambda function to generate thumbnail images when there are photos uploaded to a S3 Bucket
  • 42. Demo 2 Build a Severless Web API by using AWS Lambda client Amazon API Gateway Lambda function
  • 43. References AWS Lambda Developer Guide: http://docs.aws.amazon.com/lambda/latest/dg Introduction to AWS Lambda - Serverless Compute on Amazon Web Services: https://www.youtube.com/watch?v=eOBq__h4OJ4 AWS re:Invent 2014 | (MBL202) NEW LAUNCH: Getting Started with AWS Lambda: https://www.youtube.com/watch?v=UFj27laTWQA Technical Introduction to AWS Lambda - Serverless Compute on AWS: https://www.youtube.com/watch?v=QzipnZzAQEk Serverless Architectures - Martin Fowler
  • 44. Q & A
  • 45. THANKS FOR YOUR LISTENING

Editor's Notes

  • #6: Provision a fleet proxy machines to capture uploads For each upload, enqueuer a job to process it Provision a second fleet of machines to read and process job Pick a deployment solution Plan capacity, accounting for fault tolerance, good long-term utilization, burst capacity, etc. Monitor 24x7 for capacity, health, security, etc. Migrate to new instances types over time, keeping OS and languages runtimes patched and up to date
  • #13: Talk to audience that I just focus on function as a service
  • #23: https://cloudacademy.com/blog/microsoft-azure-functions-vs-google-cloud-functions-fight-for-serverless-cloud-domination-continues/