building event driven serverless apps by danilo poccia at codemotion dubai

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

Upload: codemotion-dubai

Post on 12-Apr-2017

119 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Building Event-Driven Serverless Applications

Danilo PocciaTechnical Evangelist

@danilopdanilop

Page 2: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

2001

Page 3: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Decentralized, two-pizza teams

Agility, autonomy, accountability, and ownership

“DevOps”

Page 4: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

You Want to BuildYour Brand New Application

Page 5: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Application+

Data

Page 6: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Application+

Data

Websites

Mobile Apps

Wearable

Page 7: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Application Data

Websites

Mobile Apps

Wearable

Page 8: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Application

Files

DB

Content +Some API Calls

API Calls

Websites

Mobile Apps

Wearable

Page 9: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Application

Files

DB

API Calls

Websites(JavaScript

Apps)

Mobile Apps

Wearable

JavaScript

API Calls

Page 10: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Application

Files

DB

API Calls

Websites(JavaScript

Apps)

Mobile Apps

Wearable

Services

API Calls

JavaScript

API Calls

Page 11: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Application

Files

DB

API Calls

Websites(JavaScript

Apps)

Mobile Apps

Wearable

Services

API Calls

JavaScriptAuthentication& Authorization

Caching & Throttling

Business Logic

API Calls

Page 12: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Application

DB

API Calls

Websites(JavaScript

Apps)

Mobile Apps

Wearable

Services

API Calls

JavaScript

Files

AmazonS3

AmazonDynamoDB

Authentication & Authorization

AmazonCognito

Business Logic

AWSLambda

Caching & Throttling

Amazon APIGatewayAPI Calls

Page 13: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

How Does It Works?

Page 14: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

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 15: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

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 16: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

AmazonCloudFront

API Gateway Cache

AmazonCloudWatch

Monitoring & Logs

Endpoints onAmazon EC2 or

AWS Elastic Beanstalk

Internet

Any other publicly accessible endpoint

AWS Lambda Functions

Caching & Throttling

Amazon APIGateway

X

Access toAPI Method

Page 17: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai
Page 18: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

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 Support

Request / Response Data Transformation and API Mocking

Page 19: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

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 20: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Build Back-end Services that Perform at Scale

Respond Quickly to New Information

Run Your Code without Managing Infrastructure

Cost-effective and Efficient

Page 21: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Amazon API Gateway+

AWS Lambda

Page 22: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Resource + HTTP Verb ➔ Method (Function)

Page 23: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Resource + HTTP Verb ➔ Method (Function)

/books + GET ➔ GetAllBooksByRange

Page 24: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Resource + HTTP Verb ➔ Method (Function)

/books + GET ➔ GetAllBooksByRange

/books + POST ➔ CreateNewBook

Page 25: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Resource + HTTP Verb ➔ Method (Function)

/books + GET ➔ GetAllBooksByRange

/books + POST ➔ CreateNewBook

/books/{id} + GET ➔ GetBookById

/books/{id} + PUT ➔ CreateOrUpdateBookById

/books/{id} + DELETE ➔ DeleteBookById

Page 26: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Let’s Put Everything Together

Page 27: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Media Sharing Application

Page 28: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

λ

λ λ

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 29: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

λ

λ λ

λ

λ

λλ

λ

λ

λ

Page 30: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Microservice Architecture

λλ λλ

λλ λλ λ

λ

Page 31: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Choreography vs Orchestration

λλ λλ

λλ λλ λ

λ

Page 32: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Reactive Programming

λλ λλ

λλ λλ λ

λ

Page 33: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Asynchronous Communication

λλ λλ

λλ λλ λ

λ

Page 34: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Eventual Consistency

λλ λλ

λλ λλ λ

λ

Page 35: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

<demo>...

</demo>

Page 36: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Focus on You Idea

Page 37: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

aws.amazon.com/free

Page 38: Building event driven serverless apps by Danilo Poccia at Codemotion Dubai

Event-driven (Serverless) Applications

Danilo PocciaAWS Technical Evangelist

@danilopdanilop