serverless apps with openwhisk -...

59
Serverless apps with Apache OpenWhisk CLOUD NATIVE ● EVENT DRIVEN ● MICROSERVICES SINA NOURIAN 1

Upload: others

Post on 26-Aug-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Serverless apps withApache OpenWhisk

CLOUD NATIVE ● EVENT DRIVEN ● MICROSERVICES

SINA NOURIAN 1

Page 2: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

• Evolution of Serverless

• Introducing OpenWhisk

• OpenWhisk Architecture

• OpenWhisk & Containers

• Demos & Use cases

• Customers & Partners

2

Agenda

Page 3: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

3

What makes serverless, event driven computing so

attractive?

Page 4: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Serverless developers focus more on code, less on infrastructure

4EVOLUTION OF SERVERLESS

Page 5: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Runs code only on-demand ona per-request basis

EVOLUTION OF SERVERLESS 5

Page 6: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Problem: Microservices can be hard to manage at scale

6EVOLUTION OF SERVERLESS

Page 7: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Serverless can handle many cloud native app 12 Factors

1. CodebaseOne codebase tracked in revision control, many deploys

2. DependenciesExplicitly declare and isolate dependencies

3. ConfigurationStore config in the environment

4. Backing servicesTreat backing services as attached resources

5. Build, release, runStrictly separate build and run stages

6. ProcessesExecute the app as one or more stateless processes

EVOLUTION OF SERVERLESS 7

Handled by developer

Handled by platform

Handled by developer, facilitated by platform

Handled by platform

Handled by platform

Handled by platform

Page 8: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Serverless can handle many cloud native app 12 Factors

7. Port bindingExport services via port binding

8. ConcurrencyScale out via the process model

9. DisposabilityMaximize robustness with fast startup and graceful shutdown

10. Dev/prod parityKeep development, staging, and production as similar as possible

11. LogsTread logs as event streams

12. Admin processesRun admin/management tasks as one-off processes

EVOLUTION OF SERVERLESS 8

Handled by platform

Handled by platform

Handled by platform

Handled by developer

Handled by developer

Handled by platform

Page 9: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Application

Problem: Programming and pricing models aren’t efficient

• Continuous polling needed in the absence of an event driven programming model

• Charged for resources, even when idle

• Worries persist about capacity management

EVOLUTION OF SERVERLESS 9

Request Polling

CF Container VM

Page 10: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Event-programming model • Runs code in response to events

EVOLUTION OF SERVERLESS 10

Page 11: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Emerging workloads are a good fit for event-driven programming

EVOLUTION OF SERVERLESS 11

Page 12: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

New cost models more accurately charge for usage

• Cloud resource cost better matches business value gained

EVOLUTION OF SERVERLESS 12

Page 13: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Technological and business factors make serverless compelling

EVOLUTION OF SERVERLESS 13

Page 14: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

A couple of examples• UI-driven application

• Traditional architecture

EVOLUTION OF SERVERLESS 14

Page 15: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

A couple of examples• UI-driven application

• Serverless BaaS architecture

EVOLUTION OF SERVERLESS 15

Page 16: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

A couple of examples

EVOLUTION OF SERVERLESS 16

• Message-driven application• Traditional architecture

Page 17: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

A couple of examples

EVOLUTION OF SERVERLESS 17

• Message-driven application• Serverless FaaS architecture

Page 18: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Comparison with PaaS

EVOLUTION OF SERVERLESS 18

Page 19: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Available Serverless Solutions

FUNCTION AS A SERVICE (FAAS)

• Microsoft Azure Functions

• Google Cloud Functions

• Amazon Lambda

• IBM/Apache OpenWhisk

• Iron.io IronWorker

• Joyent Manta Functions

• PubNub BLOCKS

• Serverless Docker

BACKEND AS A SERVICE (BAAS)

• Amazon API Gateway

• Amazon Cognito

• AWS DynamoDB

• Google Cloud Datastore

• Google Firebase

• AnyPresence

• Appery.io

• BaaSBox

19EVOLUTION OF SERVERLESS

Page 20: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Drawbacks• Vendor control

• Multitenancy Problems

• Vendor lock-in

• Security concerns

• Loss of Server optimizations

• No in-server state for Serverless FaaS

EVOLUTION OF SERVERLESS 20

Page 21: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

21

IntroducingOpenWhisk

Page 22: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

FaaS platform to execute code in response to events• Provides serverless deployment and operations

model

• Runs code only on-demand on a per-request basis

• Optimized utilization, fine-grained metering at any scale

• Flexible, extensible, polyglot programming model

• Open source and open ecosystem (Apache Incubator)

• Ability to run in public, private, and hybrid models

INTRODUCING OPENWHISK 22

Page 23: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Developers work with packages, triggers, actions, and rules

INTRODUCING OPENWHISK 23

Page 24: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Triggers

INTRODUCING OPENWHISK 24

T A class of events that can occur

Page 25: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Actions

INTRODUCING OPENWHISK 25

ACode that runs in response to an event(that is, an event handler)

Page 26: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Actions

INTRODUCING OPENWHISK 26

ACan be written in a variety of languages, such asJavaScript, Python, Java, Swift, …

Page 27: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Actions

INTRODUCING OPENWHISK 27

A Or any other language by packaging with Docker

Page 28: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Actions

INTRODUCING OPENWHISK 28

ACan be composed to create sequencesthat increase flexibility and foster reuse

Page 29: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Rules

INTRODUCING OPENWHISK 29

RAn association of a trigger to an actionin a many to many mapping.

Page 30: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Packages

INTRODUCING OPENWHISK 30

P A shared collection of triggers and actions

Page 31: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

OpenWhisk enables event driven applications

An event occurs, for example

• Commit pushed to Github repository

• Data changed in Cloudant

INTRODUCING OPENWHISK 31

Which triggers execution ofassociated OpenWhisk action

Page 32: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

OpenWhisk can implement REST microservices

INTRODUCING OPENWHISK 32

Page 33: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Creating the action

INTRODUCING OPENWHISK 33

Page 34: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

34

OpenWhiskArchitecture

Page 35: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

OpenWhisk under the hood: Developer view

1. Router receives request to API via CLI or UI

2. Controller checks entitlement and dispatches requests to Kafka

3. Invokers pull requests from CouchDB and start execution of the action

OPENWHISK ARCHITECTURE 35

Page 36: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

OpenWhisk under the hood:A deeper look

OPENWHISK ARCHITECTURE 36

Page 37: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Entering the NGINX

OPENWHISK ARCHITECTURE 37

Page 38: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Storing the results

OPENWHISK ARCHITECTURE 38

Page 39: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

OpenWhisk container model

OPENWHISK ARCHITECTURE 39

Page 40: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

OpenWhisk container model

OPENWHISK ARCHITECTURE 40

Page 41: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

OpenWhisk container model

OPENWHISK ARCHITECTURE 41

Page 42: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

OpenWhisk container model

OPENWHISK ARCHITECTURE 42

Action containers

• Host user-written function

• Maintain the illusion that“action ≈ function”

• Provide a simple REST API to:• Initialize the container

• Run the function

Page 43: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

OpenWhisk container model

OPENWHISK ARCHITECTURE 43

• Action container lifecycle

Page 44: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

44

OpenWhisk & Containers

Page 45: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Behind the scenes:It’s about containers

OPENWHISK & CONTAINERS 45

• Basically, OpenWhisk is based on Docker… but we added some smartness to meet our performance goals…

Page 46: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Behind the scenes:It’s about containers

OPENWHISK & CONTAINERS 46

Page 47: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Behind the scenes:It’s about containers

OPENWHISK & CONTAINERS 47

Page 48: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Behind the scenes:It’s about containers

OPENWHISK & CONTAINERS 48

Page 49: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Performance is king…

OPENWHISK & CONTAINERS 49

Page 50: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

50

Demos & Use cases

Page 51: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Create a timer triggered action

DEMOS & USE CASES 51

Page 52: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Create a Slack bot

DEMOS & USE CASES 52

Page 53: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

IoT

DEMOS & USE CASES 53

Page 54: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Data Processing

DEMOS & USE CASES 54

Page 55: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

55

Customers & Partners

Page 56: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

Customers and Partners

CUSTOMERS & PARTNERS 56

Page 57: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

What do customers do with OpenWhisk?

CUSTOMERS & PARTNERS 57

Page 58: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

What do customers do with OpenWhisk?

CUSTOMERS & PARTNERS 58

Page 59: Serverless apps with OpenWhisk - webpages.iust.ac.irwebpages.iust.ac.ir/morteza_zakeri/repo/iust_course_materials/Grid... · Serverless apps with Apache OpenWhisk CLOUD NATIVE EVENT

59

Q&A