serverless architectures - entwicklertag · ser verless is about the of ser vers. build and run...

55
ARCHITECTURES (WITH INFRASTRUCTURE) Niko Köbler Soware-Architect, Developer & Trainer | | SERVERLESS AWS [email protected] www.n-k.de @dasniko

Upload: duongkhanh

Post on 19-Jul-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

ARCHITECTURES(WITH INFRASTRUCTURE)

Niko Köbler So�ware-Architect, Developer & Trainer

| |

SERVERLESS

AWS

[email protected] www.n-k.de @dasniko

Page 3: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

DISCLAIMERThis is silver bullet,

no standard, but opinionated!

NO

Page 6: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

This is what actually mean...serverless

Page 7: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about
Page 8: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about
Page 9: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

Serverless is about the of servers.

Build and run applications servers.

management

without thinkingabout

Page 10: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

OF COMPUTINGPhysical Servers in datacentersVirtual Machines in datacentersVirtual Machines in CloudContainers on Virtual MachinesServerless as the unit of compute

EVOLUTION

Page 11: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

COMPUTE Functions are the unit of deployment and scaling.No machines, VMs, or containers visible in theprogramming model.Permanent storage lives elsewhere.Scales per request; Users cannot over- or under-provision capacity.Never pay for idle (no cold servers/containers or their costs).Implicitly fault-tolerant because functions can runanywhere.BYOC - Bring Your Own Code.Metrics and logging are a universal right.

SERVERLESS MANIFESTO

Page 12: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

Source: various AWS presentations

Page 13: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

?Unit of deployment and scale!

PAAS

Page 16: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

AWS Event Driven

JVM-based languages (Java 8), JavaScript (Node.js), Python, C#, (more to come)

Versions, Encrypted Environment Variables, Step Functions

Pay as you use - in 100ms blocks (e.g. 100ms w/ 128MB memory = USD 0.000000208)

LAMBDA

Page 17: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

AWS EXAMPLE

LAMBDANODE

exports.handler = (event, context) => { console.log('Received event:', JSON.stringify(event)); }

Page 18: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

AWS EXAMPLE

LAMBDAJAVA

public class ImageProcessor implements RequestHandler<S3Event, Void> { @Override public Void handleRequest(S3Event s3Event, Context context) {

// get the S3 event data from the event request S3EventNotification.S3EventNotificationRecord record = s3Event.getRecords().get(0);

// your code goes here...

// return an object with specified type (see class generics) return null; } }

Page 21: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

GATEWAY"Reverse Proxy"

hides possible multiple service calls (aka "service composition", ESB?)

distributes requests to proper service instances

"Mock" services

Caching, Throttling, DDoS attack protection, etc.

API

Page 23: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about
Page 24: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

GATEWAY"Reverse Proxy"

hides possible multiple service calls (aka "service composition", ESB?)

distributes requests to proper service instances

"Mock" services

Caching, Throttling, DDoS attack protection, etc.

API

Page 25: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

GATEWAYAUTHENTICATION / AUTHORIZATION

AWS Cognito / STS

Custom Authorizer (Lambda Function, returning IAM policies)

API

Page 26: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

API GATEWAY AUTHORIZATION

Page 28: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about
Page 30: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

DYNAMOFully Managed NoSQL Data Store

Schemaless Data Model

Seamless Scalabiltiy, "no limits"

Pay by Read-/Write-Capacity-Units

DB

Page 32: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

SERVERLESS ARCHITECTUREWEB

Page 33: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

SERVERLESS ARCHITECTUREWEB

Page 34: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about
Page 35: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about
Page 37: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about
Page 38: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

SKILLSBOTS (CHAT/VOICE)

ALEXA

Page 39: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

TESTING

Page 40: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

TESTING

Functions are easy to test, stateless and little to no dependencies

UNIT TESTS

Page 41: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

TESTING

Environment, Infrastructuremax. 1024 of running processes/threads

max. 100 concurrent Lambdas per Region no remote debugging

INTEGRATION TESTS

Page 43: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

GOOGLECLOUD FUNCTIONS

JavaScript

COMPETITOR

Page 44: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

MICROSOFTAZURE FUNCTIONS

JavaScript, C#, Python, PHP

COMPETITOR

Page 46: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

COMPETITOR

IBM BLUEMIX

Bluemix Cloud & OnPremiseOpen Source / Apache License v2.0JavaScript (Node.js), Python and... Swi�!Docker SupportFunction-Chaining

OPENWHISK

Page 47: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

IBM

LET'S GET STARTEDOPENWHISK

$ git clone https://github.com/openwhisk/openwhisk.git $ cd openwhisk/tools/vagrant $ vagrant up

Page 48: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

IBM JAVASCRIPT EXAMPLE

Create the action in OpenWhisk

Run the action

Result

OPENWHISK

function main(params) { return {payload: 'Hello, ' + params.name}; }

$ wsk action create hello hello.js

$ wsk action invoke hello --blocking --result --param name Niko

{ "payload": "Hello, Niko" }

Page 49: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about
Page 50: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

Overview: Documentation, Logging & Monitoring, Metrics ! (typical things for distributed environments)

Cloud Provider Binding / Dependency: APIs, Portability, Costs, SLAs

DRAWBACKS

Page 51: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

?WANT TO START?

Give a try!

Manages all the Cloud-Resources and Deployment.

CURIOUS

serverless.com

Page 52: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

SERVERLESS.COM# Install serverless globally $ npm install serverless -g

# Create an AWS Lamdba function in Node.js $ serverless create --template aws-nodejs

# Deploy to live AWS account $ serverless deploy

# Function deployed! $ http://api.amazon.com/users/update

Page 53: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

BUT POWERFUL

No need to run/manage Application ServersFast results, minimal effort, minimal TTM(!)Low costs, minimal financial riskAutomatic Scalabiltiy and Availability "out-of-the-box"

SERVERLESS

Page 54: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

THANK !ANY ?

Slides:

Niko Köbler So�ware-Architect, Developer & Trainer

| |

YOUQUESTIONS

http://bit.ly/serverless-slides

[email protected] www.n-k.de @dasniko

Page 55: SERVERLESS ARCHITECTURES - Entwicklertag · Ser verless is about the of ser vers. Build and run applications ser vers. management without thinking about

LINKSAWS Lambda: Amazon API Gateway:

Google Cloud Functions:

Microso� Azure Functions:

IBM OpenWhisk: IBM OpenWhisk SourceCode:

Serverless Framework:

https://aws.amazon.com/lambdahttps://aws.amazon.com/api-

gateway

https://cloud.google.com/functions

https://azure.microso�.com/services/functionshttps://developer.ibm.com/openwhisk

https://github.com/openwhisk/openwhiskhttp://serverless.com