building event-driven serverless applications - aws - danilo poccia

43
Building Event-Driven Serverless Applications Danilo Poccia Technical Evangelist @danilop danilop

Upload: it-talent-college

Post on 26-Jan-2017

68 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Building Event-Driven Serverless Applications

Danilo PocciaTechnical Evangelist

@danilopdanilop

Page 2: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

2001

Page 3: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Decentralized, two-pizza teams

Agility, autonomy, accountability,and ownership

“DevOps”

Page 4: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

You Want to BuildYour Brand New Application

Page 5: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Application+

Data

Page 6: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Application+

Data

Websites

Mobile Apps

Wearable

Page 7: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Application Data

Websites

Mobile Apps

Wearable

Page 8: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Application

Files

DB

Content +Some API Calls

API Calls

Websites

Mobile Apps

Wearable

Page 9: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Application

Files

DB

API Calls

Websites(JavaScript

Apps)

Mobile Apps

Wearable

JavaScript

API Calls

Page 10: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Application

Files

DB

API Calls

Websites(JavaScript

Apps)

Mobile Apps

Wearable

Services

API Calls

JavaScript

API Calls

Page 11: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Application

Files

DB

API Calls

Websites(JavaScript

Apps)

Mobile Apps

Wearable

Services

API Calls

JavaScriptAuthentication& Authorization

APIManagement,

Caching & Throttling

Business Logic

API Calls

Page 12: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Application

DB

API Calls

Websites(JavaScript

Apps)

Mobile Apps

Wearable

Services

API Calls

JavaScript

Files

AmazonS3

AmazonDynamoDB

API Calls

Authentication& Authorization

APIManagement,

Caching & Throttling

Business Logic

Page 13: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Application

DB

API Calls

Websites(JavaScript

Apps)

Mobile Apps

Wearable

Services

API Calls

JavaScript

Files

AmazonS3

AmazonDynamoDB

Authentication & Authorization

AmazonCognito

Business Logic

AWSLambda

API Management,Caching & Throttling

Amazon APIGatewayAPI Calls

Page 14: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

How Does It Works?

Page 15: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

X

AuthenticationProviders

End Users

User Credentials

AuthenticationToken

Amazon CognitoIdentity Broker

Identity Pool Id(Token)

Identity IdAWS Temp Credentials

(Depending onAuth / Unauth Role)

Access toAWS Services

(Including AmazonAPI Gateway)

Identity IdAWS Temp Credentials

Amazon S3

AmazonDynamoDB

AmazonMobile Analytics

Amazon CognitoSync Store

K / V

Authentication & Authorization

AmazonCognitoCheck Token

Page 16: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

X

End Users

User Credentials

AuthenticationToken

Amazon CognitoIdentity Broker

Identity Pool Id(Token)

Identity IdAWS Temp Credentials

(Depending onAuth / Unauth Role)

Access toAWS Services

(Including AmazonAPI Gateway)

Identity IdAWS Temp Credentials

Amazon S3

AmazonDynamoDB

AmazonMobile Analytics

Amazon CognitoSync Store

K / V

Custom Authentication

ServiceGet Token

Token Authentication & Authorization

AmazonCognito

Page 17: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

X

End Users

User Credentials

AuthenticationToken

Amazon CognitoIdentity Broker

Identity Pool Id(Token)

Identity IdAWS Temp Credentials

(Depending onAuth / Unauth Role)

Access toAWS Services

(Including AmazonAPI Gateway)

Identity IdAWS Temp Credentials

Amazon S3

AmazonDynamoDB

AmazonMobile Analytics

Amazon CognitoSync Store

K / V

Amazon CognitoUser Pools

Get Token

Token Authentication & Authorization

AmazonCognito

Page 18: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Amazon Cognito

User Pools

Page 19: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

AmazonCloudFront

API Gateway Cache

AmazonCloudWatch

Monitoring & Logs

Endpoints onAmazon EC2 or

AWS Elastic Beanstalk

Internet

Any other publicly accessible endpoint

AWS Lambda Functions

API Management,Caching & Throttling

Amazon APIGateway

X

Access toAPI Method

Page 20: Building Event-Driven Serverless Applications - AWS - Danilo Poccia
Page 21: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Managed Cache to Store API Responses

Reduced Latency and DDoS Protection through Amazon CloudFront

SDK Generation for iOS, Android and JavaScript

HTTP 429 Response for API Throttling (Managed by the SDK)

Swagger Import / Export Support

Request / Response Data Transformation and API Mocking

Custom Authorization

Page 22: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Business Logic

AWSLambda

AWSLambda

Functions

AmazonAPI Gateway Amazon S3

AmazonDynamoDB

Amazon CognitoSync Store

K / VAmazonSNS

AmazonKinesis

Alexa Skills Kit (ASK)Alexa Voice Service (AVS)

HTTPSInvoke

CustomEvents

HTTPSREST

API Call

AmazonSES

AmazonSWF

AWS IoT

?

?

?

?

???

AmazonCloudWatch

Events

Page 23: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Build Back-end Services that Perform at Scale

Respond Quickly to New Information

Run Your Code without Managing Infrastructure

Cost-effective and Efficient

Page 24: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Amazon API Gateway+

AWS Lambda

Page 25: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Resource + HTTP Verb ➔ Method (Function)

Page 26: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Resource + HTTP Verb ➔ Method (Function)

/books + GET ➔ GetAllBooksByRange

Page 27: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Resource + HTTP Verb ➔ Method (Function)

/books + GET ➔ GetAllBooksByRange

/books + POST ➔ CreateNewBook

Page 28: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Resource + HTTP Verb ➔ Method (Function)

/books + GET ➔ GetAllBooksByRange

/books + POST ➔ CreateNewBook

/books/{id} + GET ➔ GetBookById

/books/{id} + PUT ➔ CreateOrUpdateBookById

/books/{id} + DELETE ➔ DeleteBookById

Page 29: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

<hands-on>...

</hands-on>

Page 30: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Let’s Put Everything Together

Page 31: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Media Sharing Application

Page 32: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

λ

λ λ

AmazonAPI Gateway

λ

λ

λλ

Bucket Usage Table

Media MetadataTable

User StatTable

User Location

Table

K / V

λ

λ

λ

Amazon CognitoIdentity Broker

Amazon CognitoSync Store

AmazonSNS

AmazonKinesis

Media Bucket

LogTable

Authentication &

AuthorizationUpload Picture / VideoUpdate Bucket UsageCheck Bucket Usage

Delete “Over Quota”

Media

Send Notification to

User / Application

Extract Metadata and Write on DB

Update User StatisticsCall REST API

to Get Media Description

Upload Location Info

Update User Location

Look for Users or Media

Near Current Location

Call REST API to Get

User Info

Sync Media and User

Rating

Write History of ChangesCheck and Update

Ratings

InvokeRead

Write / Send

Page 33: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

λ

λ λ

λ

λ

λλ

λ

λ

λ

Page 34: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Microservice Architecture

λλ λλ

λλ λλ λ

λ

Page 35: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Choreography vs Orchestration

λλ λλ

λλ λλ λ

λ

Page 36: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Reactive Programming

λλ λλ

λλ λλ λ

λ

Page 37: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Asynchronous Communication

λλ λλ

λλ λλ λ

λ

Page 38: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Eventual Consistency

λλ λλ

λλ λλ λ

λ

Page 39: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

“If you wantto increase innovation,

you have to lowerthe cost of failure.”

Joi Ito, Director,MIT Media Lab

Page 40: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Focus on Your Idea

Page 41: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

aws.amazon.com/free

Page 42: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

aws.amazon.com/education/awseducate

AWS Educate

Page 43: Building Event-Driven Serverless Applications - AWS - Danilo Poccia

Building Event-Driven Serverless Applications

Danilo PocciaTechnical Evangelist

@danilopdanilop