3. a cloud-native platform
for
short-running, stateless computation
and
event-driven applications
which
scales up and down instantly and automatically
and
charges for actual usage at a millisecond granularity
event
handlersevents
What is Serverless?
6. What is OpenWhisk?
a high-level serverless programming model
Trigger
Rule
Action
Package
7. What is OpenWhisk?
a high-level serverless programming model
Trigger
Rule
Action
Package
language support to
encapsulate, share, extend code
first-class
event-driven
programming
constructs
first-class functions
compose via sequences
docker
containers as
actions
all constructs first-class
— powerful extensible
language
8. What is OpenWhisk
under the hood?
http://fordmustanglover.blogspot.com/
• Basic Runtime
• Meta-programming
10. Edge
VMEdge
VM
Edge VM
Edge
VM
Edge
VM
Master VM
controller
Edge
VM
Edge
VM
Slave VM
invoker
• microservices deployed in docker containers
• open-source system middleware
• NoSQL (CouchDB) persistence
action
container
action
containeraction
container
action
containeraction
containeraction
container
action
containeraction
container
16. Step 1. Entering the system
Edge
VMEdge
VM
Edge VM
Edge
VM
Edge
VM
Master VM
controller
Why
POST /api/v1/namespaces/myNamespace/actions/myAction
?
• SSL termination
• Load Balancing
• Blue/Green continuous delivery
20. Step 4. Get the action
scala
kafka
SDK
couchDB
SDK
spray
DSL
load
balancer
consul
SDK
data
models
authcaching
• check resource limits
• actions stored as documents in CouchDB
• binaries as objects (attachments)
actors
controller
21. Step 5. Looking for a home
scala
kafka
SDK
couchDB
SDK
spray
DSL
load
balancer
consul
SDK
data
models
authcaching
controller
Load balancer: find a slave to execute
Slave health, load stored in consul
• Sequentially consistent KV store
• Replication, Fault Tolerance
• Health Check / Monitoring utilities
Why ?
actors
22. Step 6. Get in line!
scala
kafka
SDK
couchDB
SDK
spray
DSL
load
balancer
consul
SDK
data
models
authcaching
invoker
Why ?
• High throughput fault-tolerant queues
• Point-to-point messages via topics
• explicit load balancing
Post request to execute to queue in
actors
Master VM
Master VM Slave VM
controller
24. Slave VM
Step 7. Get to work!
scala
kafka
SDK
couchDB
SDK
docker
utilities
container
pool
consul
SDK
data
models
caching
invoker
bound to
user action
• each user action gets it own container (isolation)
• containers may be reused
• container pool allocates and garbage collects containers
stem cell
actors
User action containers
26. Step 8. Store the results.
scala
kafka
SDK
couchDB
SDK
docker
utilities
container
pool
consul
SDK
data
models
caching
invoker
action
container
HTTPResponse
logs on filesystem
actors
27. median ~45 ms latency end-to-end
(unloaded system, hello world)
30. using OpenWhisk feeds
wsk package bind /whisk.system/github myGit --param username
myGitUser --param repository myGitRepo --param accessToken
aaaaa1111a1a1a1a1a111111aaaaaa1111aa1a1a
1 Bind a Package with your credentials (parameters)
31. using OpenWhisk feeds
wsk package bind /whisk.system/github myGit --param username
myGitUser --param repository myGitRepo --param accessToken
aaaaa1111a1a1a1a1a111111aaaaaa1111aa1a1a
wsk trigger create myGitTrigger --feed myGit/webhook --param
events push
1 Bind a Package with your credentials (parameters)
2 Create a Trigger (instantiate a stream of events)
32. using OpenWhisk feeds
wsk package bind /whisk.system/github myGit --param username
myGitUser --param repository myGitRepo --param accessToken
aaaaa1111a1a1a1a1a111111aaaaaa1111aa1a1a
wsk trigger create myGitTrigger --feed myGit/webhook --param
events push
wsk rule create R myGitTrigger myAction
1 Bind a Package with your credentials (parameters)
2 Create a Trigger (instantiate a stream of events)
3 Create a Rule (hook trigger to an action)
33. anybody can create a Package with a feed
/whisk.system/github /mynamespace/github
34. logical architecture of a github feed service
REST API
Create feed
POST /feeds
Read feed
GET /feeds/{id}
Update Feed
PUT /feeds/{id}
Delete feed
DELETE /feeds/{id}
wsk trigger create
35. what’s the easiest way to implement a service?
REST API
Create feed
POST /feeds
Read feed
GET /feeds/{id}
Update Feed
PUT /feeds/{id}
Delete feed
DELETE /feeds/{id}
36. what’s the easiest way to implement a service?
REST API
Create feed
POST /feeds
Read feed
GET /feeds/{id}
Update Feed
PUT /feeds/{id}
Delete feed
DELETE /feeds/{id}
37. logical architecture of a github feed service
serverless feed action
main(params) {
…
params.lifecycle ==
Create
Read
Update
Delete
}
wsk trigger create
42. T A B C
sequence
R
cloud
debug> break on B
…
debug> inspect ..
developer
laptop
43. T A B C
sequence
R
cloud
debug> break on B
…
debug> inspect ..
developer
laptop
But how ?
• Serverless runtime is stateless, short-running
• debugging tools (Chrome, lldb, ..) are local
47. T A B C
R
% (wskdb) attach b
create jump action Bj% wsk action create Bj ..
48. T A B C
R
% (wskdb) attach b
create jump action Bj
Bccreate continue action
% wsk action create Bj ..
% wsk action create Bc ..
49. T A B C
R
% (wskdb) attach b
T A Bj
Rj
create jump action Bj
Bccreate continue action
create jump rule
% wsk action create Bj ..
% wsk action create Bc ..
% wsk rule create Rj A Bj
50. T A B C
R
% (wskdb) attach b
T A Bj
Rj
T2 Bc C
Rc
create jump action Bj
Bccreate continue action
create continue rule
create jump rule
% wsk action create Bj ..
% wsk action create Bc ..
% wsk rule create Rj A Bj
% wsk rule create Rc Bc C
51. T A B C
R
% (wskdb) attach b
T A Bj
Rj
T2 Bc C
Rc
create jump action Bj
Bccreate continue action
create continue rule
create jump rule
start up local debug broker
% wsk action create Bj ..
% wsk action create Bc ..
% wsk rule create Rj A Bj
% wsk rule create Rc Rc C
57. All the debugger components are unprivileged user code
debugging
broker
(wskdb)
T A Bj
Rj
T2 Bc C
Rc
Bj Bc
Uses OpenWhisk introspection to examine and rewrite the user
code using actions, triggers, rules.
https://github.com/openwhisk/openwhisk-debugger