ibm bluemix paris meetup #22-20170315 meetup @villagebyca - serverless & openwhisk

Post on 21-Mar-2017

62 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

© 2016 IBM Corporation© 2016 IBM Corporation

Introduction to serverless and OpenWhisk

© 2016 IBM Corporation© 2016 IBM Corporation

THE CASE FOR SERVERLESS

© 2016 IBM Corporation© 2016 IBM Corporation

Welcome to Industrial internet!

© 2016 IBM Corporation© 2016 IBM Corporation

Devices can be...

© 2016 IBM Corporation© 2016 IBM Corporation

How would you implement it?

© 2016 IBM Corporation© 2016 IBM Corporation

OK, let’s move step by step

© 2016 IBM Corporation© 2016 IBM Corporation

And if you want it to be HA?

© 2016 IBM Corporation© 2016 IBM Corporation

What about another device?

© 2016 IBM Corporation© 2016 IBM Corporation

Let’s be smart!

© 2016 IBM Corporation© 2016 IBM Corporation

An unexpected spike!

© 2016 IBM Corporation© 2016 IBM Corporation

Scaling out!

© 2016 IBM Corporation© 2016 IBM Corporation

And traffic goes down...

© 2016 IBM Corporation© 2016 IBM Corporation

An excessive compute?

© 2016 IBM Corporation© 2016 IBM Corporation

Or maybe those ones?

© 2016 IBM Corporation© 2016 IBM Corporation

And in the meantime...

© 2016 IBM Corporation© 2016 IBM Corporation

And further down...

© 2016 IBM Corporation© 2016 IBM Corporation

And...

© 2016 IBM Corporation© 2016 IBM Corporation

Ideal case

© 2016 IBM Corporation© 2016 IBM Corporation

Compute follows traffic

© 2016 IBM Corporation© 2016 IBM Corporation

Compute follows traffic

© 2016 IBM Corporation© 2016 IBM Corporation

So what are the requirements?

● Invoke and scale as fast as possible● Terminate after completion

© 2016 IBM Corporation© 2016 IBM Corporation

So what are the requirements?

● Invoke and scale as fast as possible● Terminate after completion● Charge per compute used

© 2016 IBM Corporation© 2016 IBM Corporation

So what are the requirements?

● Invoke and scale as fast as possible● Terminate after completion● Charge per compute used● Guaranteed message delivery● Load balancing

© 2016 IBM Corporation© 2016 IBM Corporation

So what are the requirements?

● Invoke and scale as fast as possible● Terminate after completion● Charge per compute used● Guaranteed message delivery● Load balancing● High availability● Self-healing

© 2016 IBM Corporation© 2016 IBM Corporation

So what are the requirements?

● Invoke and scale as fast as possible● Terminate after completion● Charge per compute used● Guaranteed message delivery● Load balancing● High availability● Self-healing

● Support of multiple technologies

● Have possibility to launch other microservices

● Write and read data from multiple data sources

© 2016 IBM Corporation© 2016 IBM Corporation

So what are the requirements?

● Invoke and scale as fast as possible● Terminate after completion● Charge per compute used● Guaranteed message delivery● Load balancing● High availability● Self-healing

● Support of multiple technologies

● Have possibility to launch other microservices

● Write and read data from multiple data sources

● Abstract developers from the infrastructure

© 2016 IBM Corporation© 2016 IBM Corporation

Twelve Factor App was created as a methodology for building SaaS…

I. CodebaseOne codebase tracked in revision control, many deploys

II. DependenciesExplicitly declare and isolate dependencies

III. ConfigStore config in the environment

IV. Backing servicesTreat backing services as attached resources

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

VI. ProcessesExecute the app as one or more stateless processes

https://12factor.net/VII. Port bindingExport services via port binding

VIII. ConcurrencyScale out via the process model

IX. DisposabilityMaximize robustness with fast startup and graceful shutdown

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

XI. LogsTreat logs as event streams

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

Serverless and the 12 Factor App?

© 2016 IBM Corporation© 2016 IBM Corporation

SERVERLESS

&

OPENWHISK

© 2016 IBM Corporation© 2016 IBM Corporation

OpenWhisk in a nutshell

„Event-action platform to execute code in response to events“

* whisk (v): to move nimbly and quickly (source: merriam-webster.com)

© 2016 IBM Corporation© 2016 IBM Corporation

OpenWhisk in a nutshell

„Event-action platform to execute code in response to events“

Delivered as open source & managed service on IBM Bluemix

* whisk (v): to move nimbly and quickly (source: merriam-webster.com)

© 2016 IBM Corporation© 2016 IBM Corporation

Swift

Application

Container VMCF

2

Polling

1b

Request

1a

• Continuous polling

• Charges even when idling due to poor utilization

• Worry about scaling- When to scale? (mem-, cpu-, response time-driven)- How fast to scale?

• Worry about resiliency- At least 2 processes for HA (driving cost)- Deployment in multiple regions (driving cost)- Keep them running & healthy Process & idle

Traditional model

© 2016 IBM Corporation© 2016 IBM Corporation

• Introduces event programming model

• Charges only for what is used due to optimal utilization

• Scales inherently- One process per request

• No cost overhead for resiliency- No long running process for HA

3

Running action

1

Trigger

2Pool of actions

Swift DockerJS

Running action

Running action

Deploy action within millisecs,run it, free up resources

OpenWhisk Engine

OpenWhisk model

© 2016 IBM Corporation© 2016 IBM Corporation

} 1

Event Providers

OpenWhisk

Cloudant

Push Notifcations

IoT message

File Storage

Data event occurs, e.g.-Commit on a Git Repository-CRUD operation on Cloudant-….

Trigger execution of associated OpenWhisk action

2

…JS Swift Docker …

Action triggered by an external event

© 2016 IBM Corporation© 2016 IBM Corporation

OpenWhisk

JS Swift Docker …

Incoming HTTP request, e.g.HTTP GET mynewcoolapp.com/customers

1 2 Invoke associated OpenWhisk action „getCustomers“

Browser

Mobile App

Web App

Variety of languages

Action triggered directly by an application (Action as API)

© 2016 IBM Corporation© 2016 IBM Corporation

Actions are only alive for the duration of the execution!

Trigger+Action = Rule

Java Python JavaScript Swift Container

Polyglot action implementation

Trigger

Event

Action

© 2016 IBM Corporation© 2016 IBM Corporation

• Services define the events they emit as triggers, and developers associate the actions to handle the events via rules

• The developer only needs to care about implementing the desired application logic - the system handles the rest

T R A

Triggers > Rules > Actions

© 2016 IBM Corporation© 2016 IBM Corporation

Trigger: „A class of events that can happen“T

Trigger

© 2016 IBM Corporation© 2016 IBM Corporation

A Actions: „An event-handler, i.e. code that runs in response to an event“

Action

© 2016 IBM Corporation© 2016 IBM Corporation

A

AA:= A1

+ A2+ A3

AB:= A2

+ A1+ A3

AC:= A3

+ A1+ A2

Actions: Can be chained to create sequences to increase flexibility and foster reuse

Action Sequence

© 2016 IBM Corporation© 2016 IBM Corporation

R

R := T A

Rules: „An association of a trigger and an action“

Rule

© 2016 IBM Corporation© 2016 IBM Corporation

myActionmyFeedT

A

Packages: „A shared collection of triggers and actions“P

A forecast

OpenSource YoursThird

Party

translatelanguageIdtextToSpeechA

AA

databaseCreatedocumentRead...changesT

AAA

Push Notifications

sendMessagewebhookT

A

webhookT

postA

WebsocketsendA

Package

© 2016 IBM Corporation© 2016 IBM Corporation

Some usage Scenarios

Microservices-based apps / APIs

Mobile Backends

Data (Stream) Processing

IoT

Cognitive

Bots

© 2016 IBM Corporation© 2016 IBM Corporation

What is serverless good for?

© 2016 IBM Corporation© 2016 IBM Corporation

Less is more… Avoid heavy-weight functions• Harder to debug• Harder to reuse

Triggers do not guarantee order of processing…• Message affinity is bad… avoid it at all costs

Plan how your input and output are designed to maximize reuse• Ability to re-use an action depends on the assumption it is making about its input• Assert aggressively!

What should you keep in mind while working with serverless?

© 2016 IBM Corporation© 2016 IBM Corporation

You want to try OpenWhisk on your own?

• Want to try out our IBM Bluemix OpenWhisk offering?Sign-up today at: https://console.ng.bluemix.net/openwhisk/

• Want to try out our open-source OpenWhisk offering?Visit: https://developer.ibm.com/openwhisk/

Try it today

© 2016 IBM Corporation© 2016 IBM Corporation

GETTING STARTED

© 2016 IBM Corporation© 2016 IBM Corporation

https://github.com/openwhisk

OpenWhisk Command Linewsk trigger create <trigger-name>1. Creating a trigger

wsk package create <package-name>2. Creating a package

wsk action create <package>/<action> <Jar File>.jar3. Creating an action

wsk package bind /whisk.system/websocket <bind-name> -p uri ws://<url>4. Create a binding for an action

wsk rule create <rule-name> <trigger> <action>5. Create a rule for triggering an action

Installing OpenWhisk CLI can be found here: https://new-console.ng.bluemix.net/openwhisk/cli

Deploying to Bluemix

Deploying Locallygit clone --depth=1 https://github.com/openwhisk/openwhisk.git

cd openwhisk/tools/vagrant

./hello

1. Deploying OpenWhisk in a VM:

Pre-requistes:• VirtualBox• Vagrant

wsk -i property set --apihost 192.168.33.13 --auth `vagrant ssh -- cat openwhisk/ansible/files/auth.guest`

2. Setting up wsk CLI environment

Note: There are a more complete deployment of OpenWhisk described in github but this approach provides a good way to test your actions locally.

© 2016 IBM Corporation© 2016 IBM Corporation

Dark Vision

https://github.com/IBM-Bluemix/openwhisk-darkvisionapp

Discover dark data in videos with IBM Watson and IBM Bluemix OpenWhisk

© 2016 IBM Corporation© 2016 IBM Corporation

One last demo… did you like my talk?

https://github.com/l2fprod/openwhisk-emoting

Simplicity can be unsettling…

© 2016 IBM Corporation© 2016 IBM Corporation

DISCUSSION

top related