The document discusses serverless computing and Apache OpenWhisk. It describes how OpenWhisk allows developers to focus on business logic rather than infrastructure by executing code in response to events in a serverless manner. OpenWhisk provides a programming model where developers can create actions to handle triggers via rules. A number of demos are presented showing how to create triggers, actions and rules with OpenWhisk to handle events and build REST APIs.
2. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Increasingfocusonbusinesslogic
Decreasing concern (and control) over stack implementation
Bare Metal
VM VM
VM
Virtual machines
Functions
Containers
Serverless developers focus more on code, less on infrastructure
3. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Monolithic
Application
Break-down into
microservices
Make each
microservice HA
Protect against
regional outage
Region A
Region B
Microservices can be hard to manage at scale
4. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Emerging workloads are a good fit for event-driven programming
Execute logic in response to database change
Perform analytics on sensor input messages
Provide cognitive computing via chatbots
Schedule tasks performed for a short time
Invoke autoscaled APIs and mobile backends
5. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Memory
allocated
(MB)
Time executing
(milliseconds)
Instances
executing
simultaneously
(count)
Cloud resource cost
better matches
business value gained
Not a silver bullet, but this can result in
substantial savings for many workloads
New cost models more accurately charge for usage
6. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Why serverless? Mobile video game popularity is hard to predictNumberofactiveusers
(unpredictable)
Days since latest release (predictable)
Active users curve for a
new mobile game has a
predictable shape, but an
unpredictable volume
1 5 10
7. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Why serverless? Conference mobile apps have huge variations in demandNumberofactiveusers
(massivelyvariable)
Days of the week (predictable)
Active users curve for a mobile
conference app has no demand before
and after the conference, and huge
intraweek swings in demand
Monday Tuesday Wednesday Thursday
8. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Why serverless? Mobile banking often peaks massively on paydayNumberofactiveusers
(stablewithamassivepeak)
Days of the pay period (predictable)
Mobile banking apps often have
peaks in demand on payday,
once every two weeks
Friday
9. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Apache OpenWhisk
is a cloud platform
that executes code in
response to events
Apache OpenWhisk enables these serverless, event-driven workloads
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
10. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Apache
Incubator
OpenWhisk is built on solid open source foundations
11. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Apache
Incubator
The OpenWhisk ecosystem is growing
12. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
But what about PaaS and container orchestration?Increasingfocusonbusinesslogic
Decreasing concern (and control) over stack implementation
Full control over infrastructure
and maximum portability
Focus on the application and let
the platform handle the rest
Auto-scaled, event-driven applications
that respond to a variety of triggers
Containers
Applications
Functions
14. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Results
Developers work with packages, triggers, actions, and rules
Package
(feed)
Packages provide integration
with external event sources
P
Trigger
(event)
T
Data sources define events
they emit as Triggers
Rule (map)R
Action
(function)
A
Developers map Actions
to Triggers via Rules
Data sources define events
they emit as Triggers.
Developers map Actions to
Triggers via Rules.
T
A
R
15. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Triggers
A class of events that can occurT
Social events
Data changes
Device readings Location updates
User input
Invocations can be blocking, non-blocking, or periodic
16. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Actions
Code that runs in response to an event
(that is, an event handler)
A
17. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Actions
Can be written in a variety of languages, such as
JavaScript, Python, Java, PHP, and Swift
A
function main(params) {
return { message: 'Hello, ' + params.name + ' from ' + params.place };
};
Multi-
language
Support
JS/NodeJS 8
Java
Python 3
Swift 4
Docker
PHP 7
Community
Efforts
Go
Rust
Ruby
…
bash
C
18. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Actions
Can be written in a variety of languages, such as
JavaScript, Python, Java, PHP, and Swift
A
function main(params) {
return { message: 'Hello, ' + params.name + ' from ' + params.place };
};
19. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Actions
Or any other language by packaging with DockerA
20. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Actions
Can be composed to create sequences
that increase flexibility and foster reuse
A
AA := A1 + A2 + A3
AB := A2 + A1 + A3
AC := A3 + A1 + A2
Plus:
• Sequencing
• Conditionals
• Loops
• Error handling
21. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Rules
An association of a trigger to an action
in a many to many mapping.
R
R := T A
22. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Packages
A shared collection of triggers and actionsP
A
A read
write
T changes A translate A forecast
A post
T topic
Open
Source A myAction
T myFeed
Yours
T commit
Third
Party
24. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
OpenWhisk awaits events, fetches mapped code, runs it in a container
Pool of actions
Swift DockerJS
Trigger
1
Running
action
Running
action
Running
action
3
OpenWhisk
Engine
2 A
T
AAA
25. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Open source software as a service on the IBM Cloud
Open source Hosted service
Serverless engine Apache OpenWhisk IBM Cloud Functions
API Gateway LoopBack IBM API Gateway
Databases
Apache CouchDB
MySQL
IBM Cloudant
IBM Compose
Message streams Apache Kafka IBM Message Hub
26. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Demo 1: Your first OpenWhisk trigger, action, and rule
$ bx wsk action create handler handler.js
$ bx wsk action invoke --blocking handler
$ bx wsk trigger create every-20-seconds
--feed /whisk.system/alarms/alarm
--param cron "*/20 * * * * *"
--param maxTriggers 15
$ bx wsk rule create
invoke-periodically
every-20-seconds
handler
Trigger
1
Running
action
2
T
A
1. Cron syntax alarm
2. Log the current time
$ bx wsk activation poll
27. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Demo 2: Mapping an HTTP request to an action
These demo actions are written in JavaScript.
But you could write the equivalent in Swift to reuse the same skills on mobile device and backend services.
28. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Demo 3: HTTP REST APIs with full create, read, update, delete methods
29. Serverless Web and Mobile APIs@DanielKrook github.com/krook/oscon
Delivered as
Open source via Apache
openwhisk.org
Managed OpenWhisk with
IBM Cloud Functions
bluemix.net/openwhisk
Get started with Apache OpenWhisk
github.com/openwhisk
slack.openwhisk.org
twitter.com/openwhisk
medium.com/openwhisk