Serverless apps with OpenWhisk -...

Post on 26-Aug-2020

19 views 0 download

Transcript of Serverless apps with OpenWhisk -...

Serverless apps withApache OpenWhisk

CLOUD NATIVE ● EVENT DRIVEN ● MICROSERVICES

SINA NOURIAN 1

• Evolution of Serverless

• Introducing OpenWhisk

• OpenWhisk Architecture

• OpenWhisk & Containers

• Demos & Use cases

• Customers & Partners

2

Agenda

3

What makes serverless, event driven computing so

attractive?

Serverless developers focus more on code, less on infrastructure

4EVOLUTION OF SERVERLESS

Runs code only on-demand ona per-request basis

EVOLUTION OF SERVERLESS 5

Problem: Microservices can be hard to manage at scale

6EVOLUTION OF SERVERLESS

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

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

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

Event-programming model • Runs code in response to events

EVOLUTION OF SERVERLESS 10

Emerging workloads are a good fit for event-driven programming

EVOLUTION OF SERVERLESS 11

New cost models more accurately charge for usage

• Cloud resource cost better matches business value gained

EVOLUTION OF SERVERLESS 12

Technological and business factors make serverless compelling

EVOLUTION OF SERVERLESS 13

A couple of examples• UI-driven application

• Traditional architecture

EVOLUTION OF SERVERLESS 14

A couple of examples• UI-driven application

• Serverless BaaS architecture

EVOLUTION OF SERVERLESS 15

A couple of examples

EVOLUTION OF SERVERLESS 16

• Message-driven application• Traditional architecture

A couple of examples

EVOLUTION OF SERVERLESS 17

• Message-driven application• Serverless FaaS architecture

Comparison with PaaS

EVOLUTION OF SERVERLESS 18

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

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

21

IntroducingOpenWhisk

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

Developers work with packages, triggers, actions, and rules

INTRODUCING OPENWHISK 23

Triggers

INTRODUCING OPENWHISK 24

T A class of events that can occur

Actions

INTRODUCING OPENWHISK 25

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

Actions

INTRODUCING OPENWHISK 26

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

Actions

INTRODUCING OPENWHISK 27

A Or any other language by packaging with Docker

Actions

INTRODUCING OPENWHISK 28

ACan be composed to create sequencesthat increase flexibility and foster reuse

Rules

INTRODUCING OPENWHISK 29

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

Packages

INTRODUCING OPENWHISK 30

P A shared collection of triggers and actions

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

OpenWhisk can implement REST microservices

INTRODUCING OPENWHISK 32

Creating the action

INTRODUCING OPENWHISK 33

34

OpenWhiskArchitecture

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

OpenWhisk under the hood:A deeper look

OPENWHISK ARCHITECTURE 36

Entering the NGINX

OPENWHISK ARCHITECTURE 37

Storing the results

OPENWHISK ARCHITECTURE 38

OpenWhisk container model

OPENWHISK ARCHITECTURE 39

OpenWhisk container model

OPENWHISK ARCHITECTURE 40

OpenWhisk container model

OPENWHISK ARCHITECTURE 41

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

OpenWhisk container model

OPENWHISK ARCHITECTURE 43

• Action container lifecycle

44

OpenWhisk & Containers

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…

Behind the scenes:It’s about containers

OPENWHISK & CONTAINERS 46

Behind the scenes:It’s about containers

OPENWHISK & CONTAINERS 47

Behind the scenes:It’s about containers

OPENWHISK & CONTAINERS 48

Performance is king…

OPENWHISK & CONTAINERS 49

50

Demos & Use cases

Create a timer triggered action

DEMOS & USE CASES 51

Create a Slack bot

DEMOS & USE CASES 52

IoT

DEMOS & USE CASES 53

Data Processing

DEMOS & USE CASES 54

55

Customers & Partners

Customers and Partners

CUSTOMERS & PARTNERS 56

What do customers do with OpenWhisk?

CUSTOMERS & PARTNERS 57

What do customers do with OpenWhisk?

CUSTOMERS & PARTNERS 58

59

Q&A