Upload
danilo-poccia
View
865
Download
1
Embed Size (px)
Citation preview
Building Event-DrivenServerless Applications
Danilo PocciaTechnical Evangelist
@danilopdanilop
Virtual Machines
Virtual Machines Containers
Virtual Machines Containers Functions
Event-Driven in the Front End
Name
Create New User
Submit
Check the “Name” syntax is right (only letters and spaces)
Check the “Email” syntax is right ([email protected])
Create the new user using provided Name and Email
User Interface Actions
Name
Create New User
Submit
Check the “Name” syntax is right (only letters and spaces)
Check the “Email” syntax is right ([email protected])
Create the new user using provided Name and Email
User Interface ActionsObservers
Target Action
What about the Back End ?
! Users
Internet
! Users
Back End Logic
Internet
! Users
Back End Data
Back End Logic
Internet
! Users
Back End Data
Application Back End
Back End Logic
Internet
! Users
Application Back End" Web Browsers
Back End Data
Back End Logic
Application Back End" Web Browsers
# Mobile Apps Back End
Data
Back End Logic
Application Back End" Web Browsers
# Mobile Apps
$ IoT Devices
Back End Data
Back End Logic
Application Back End" Web Browsers
# Mobile Apps
$ IoT Devices
% Other Services
Back End Data
Back End Logic
Application Back End
Files
Databases
" Web Browsers
# Mobile Apps
$ IoT Devices
% Other Services
Back End Logic
HTML, CSS, JavaScript & Multimedia Content
API Calls
Application Back End" Web Browsers
# Mobile Apps
$ IoT Devices
% Other Services
Files
Databases
Back End Logic
API Calls
Application Back End
HTML, CSS, JavaScript & Multimedia Content
" Web Browsers
(JavaScript)
# Mobile Apps
$ IoT Devices
% Other Services
By using JavaScript, Web Browsers can behave
like the other clients, such as Mobile Apps
or IoT Devices
Files
Databases
Back End Logic
API Calls
Application Back End
HTML, CSS, JavaScript & Multimedia Content
" Web Browsers
(JavaScript)
# Mobile Apps
$ IoT Devices
% Other Services
Files
Databases
Back End Logic
Client Application
API Calls
Application Back End
HTML, CSS, JavaScript & Multimedia Content
The Client Application can be a Web Browser,
a Mobile App, an IoT Device,
or another Service
We can now decouple the back end implementation
from the device used by our users
Files
Databases
Back End Logic
Client Application
API Calls
Application Back End
HTML, CSS, JavaScript & Multimedia Content
The Client Application can be a Web Browser,
a Mobile App, an IoT Device,
or another Service
Files
Databases
Back End Logic
Functions as your API
Context
Function
Event AWS Lambda
Result
RequestResponse Function
Invocation
Lambda API Call
AWS Lambda Functions Synchronous Invocations
Context
Function
Event AWS Lambda
Event Function
Invocation
Lambda API Call
AWS Lambda Functions Asynchronous Invocations
ContextContextResource
ContextContextResource
Context
Function
Event AWS Lambda Managed by AWS
Not managed by AWS
Result (Optional)
Function Invocation
Resources can be files, records
in a DB, etc.
Lambda API Call
Functions can Modify Resources
Events (Context)
Events (Context)
Generated by AWS
Not generated by AWS
ContextContextResource
ContextContextResource
Context
Function
Event AWS Lambda Managed by AWS
Not managed by AWS
Result (Optional)
Function Invocation
Lambda API Call
Resources can Generate more Events
Events (Context)
Events (Context)
Generated by AWS
Not generated by AWS
ContextContextResource
ContextContextResource
AWS Lambda Managed by AWS
Not managed by AWS
Direct Use of Resource
For example, a file is uploaded
or something is written in a database
AWS Lambda
Function 2
Function 3
Function 1
Events can Trigger more Functions
Sample Event-Driven Serverless Media-Sharing Application
Client Application
Event-driven Backend&
User
Client Application
Get Content Index
Get Content
Upload Content with Metadata
Update Content Metadata
Get Content Metadata
& User
Client Application
Get Content Index
Get Content
Upload Content with Metadata
Update Content Metadata
Get Content Metadata
AWS Lambda
& User
Client Application
Get Content Index
Get Content
Upload Content with Metadata
Update Content Metadata
Get Content Metadata
Files (Multimedia)
Database
AWS Lambda
& User
Resources
Client Application
Get Content Index
Get Content and Thumbnails
Upload Content with Metadata
Update Content Metadata
Get Content Metadata
Files (Multimedia)
Database
Build Thumbnails
Update Content Index
Extract and Update Metadata
Event: new or
updated file
Event: new or updated
content metadata
AWS Lambda
& User
Resources
Get Content Index
Get Content and Thumbnails
Upload Content with Metadata
Update Content Metadata
Get Content Metadata
Files (Multimedia)
Database
Build Thumbnails
Update Content Index
Extract and Update Metadata
& User
# Mobile
App
Get Content Index
Get Content and Thumbnails
Upload Content with Metadata
Update Content Metadata
Get Content Metadata
Files (Multimedia)
Database
Build Thumbnails
Update Content Index
Extract and Update Metadata
& User
" Web Browsers
(JavaScript)
Calling Functions from the Client
Client Application
AWS Lambda Function
AWS Lambda Invoke API
& User
Calling Lambda Functions Directly
Client Application
AWS Lambda Function
AWS Lambda Invoke API
Get Temporary AWS Credentials Amazon
Cognito
& User
Getting AWS Credentials from Amazon Cognito
Client Application
AWS Lambda Function
Amazon Cognito
Amazon API Gateway
Get Temporary AWS Credentials
Web API Modeling, Caching, Throttling, Logging, CDN, etc.
& User
Exposing Functions as Web API
Client Application
AWS Lambda Function
Amazon API Gateway
Web API Modeling, Caching, Throttling, Logging, CDN, etc.
& User
Exposing Functions as Public Web API
https://some.domain/stage/resource1/resource2/…/resourceN
GETPOSTPUTDELETEHEADPATCHOPTIONS
Unique domain that you can customize
API stage, for example prod, test, dev, or v0, v1, …
Resources as part of the URL
HTTP verb used when
accessing the URL
function1function2function3function1function2
function3function1
Function to execute
Web API to Lambda Functions Integration
Web API to Lambda Functions Mapping
Resource + HTTP Verb ➔ Method
Web API to Lambda Functions Mapping
Resource + HTTP Verb ➔ Method
/books + GET ➔ GetAllBooks
Web API to Lambda Functions Mapping
Resource + HTTP Verb ➔ Method
/books + GET ➔ GetAllBooks
/books + POST ➔ CreateNewBook
Web API to Lambda Functions Mapping
Resource + HTTP Verb ➔ Method
/books + GET ➔ GetAllBooks
/books + POST ➔ CreateNewBook
/books/{id} + GET ➔ GetBookById
/books/{id} + PUT ➔ CreateOrUpdateBookById
/books/{id} + DELETE ➔ DeleteBookById
Best Practices
Distributed Systems
Distribute the Logic React to Changes
Preserve Independent Deployment
Of Functions
<demo>...
</demo>
Building Event-DrivenServerless Applications
Danilo PocciaTechnical Evangelist
@danilopdanilop