Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

OpenWhisk Under the Hood -- London Oct 16 2016

768 views

Published on

slides presented at Serverless London conference, Oct. 16 2016

Published in: Technology

OpenWhisk Under the Hood -- London Oct 16 2016

  1. 1. OpenWhisk Under the Hood Stephen Fink
  2. 2. What is OpenWhisk?
  3. 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?
  4. 4. What is OpenWhisk? an open Beta offering in IBM’s Bluemix cloud
  5. 5. What is OpenWhisk? an open-source project on github
  6. 6. What is OpenWhisk? a high-level serverless programming model Trigger Rule Action Package
  7. 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. 8. What is OpenWhisk under the hood? http://fordmustanglover.blogspot.com/ • Basic Runtime • Meta-programming
  9. 9. github.com openwhisk/openwhisk core runtime CLIpackages security features persistent store loggingmonitoring billing authentication
  10. 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
  11. 11. Why ?
  12. 12. Why ? controller invoker Deploying and managing traditional microservices 1
  13. 13. Slave VM Why ? Lightweight isolated execution environment for arbitrary user code action container action container action container action container action container action container action container action container 2
  14. 14. Why ? Portable description of arbitrary binary user actions (Dockerfile) Docker file 3
  15. 15. % wsk action invoke hello in 8 easy steps
  16. 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
  17. 17. Master VM controller Step 2. Handle the request
  18. 18. Master VM kafka SDK couchDB SDK spray DSL load balancer consul SDK data models authcaching Why scala ? Step 2. Handle the request • original prototype node.js: abandoned and rewrote • static typing • makes refactoring much easier • whole classes of bugs went away • nice concurrency features (actors/futures) • kafka libraries more stable on JVM actors controller
  19. 19. Step 3. Authentication + Authorization scala kafka SDK couchDB SDK spray DSL load balancer consul SDK data models authcaching external auth • Cloudant: hosted CouchDB • plug-in structure for custom authentication module actors controller Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
  20. 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. 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. 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
  23. 23. Slave VM invoker Step7. Get to Work!
  24. 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
  25. 25. invoker container pool cold start stem cell container docker run HTTP POST /init HTTP POST /run warm container
  26. 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. 27. median ~45 ms latency end-to-end (unloaded system, hello world)
  28. 28. Implementing feeds
  29. 29. Trigger Action Action Action custom feed example push, fork, comment, ..
  30. 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. 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. 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. 33. anybody can create a Package with a feed /whisk.system/github /mynamespace/github
  34. 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. 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. 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. 37. logical architecture of a github feed service serverless feed action main(params) { … params.lifecycle == Create Read Update Delete } wsk trigger create
  38. 38. feed action: an OpenWhisk action which manages a feed wsk trigger create myGitTrigger --feed myGit/webhook --param events push -> wsk action invoke myGit/webhook --param events push —-param lifecyleEvent ‘CREATE’ —-param triggerName myNamespace/myGitTrigger —-param auth myAuthKey …
  39. 39. wsk package create myGitPackage wsk action create myGitPackage/myFeedAction action.js wsk package update myGitPackage --shared Create your own package and share it /yourNamespace/myGitPackage
  40. 40. More Meta-Programming Building an OpenWhisk debugger in OpenWhisk
  41. 41. T A B C sequence R cloud
  42. 42. T A B C sequence R cloud debug> break on B … debug> inspect .. developer laptop
  43. 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
  44. 44. Implementing a breakpoint ld push store add jmp sub ld push debug: push … ret
  45. 45. T A B C R % (wskdb) attach b
  46. 46. T A B C R % (wskdb) attach b create jump action Bj% wsk action create Bj ..
  47. 47. T A B C R % (wskdb) attach b create jump action Bj Bccreate continue action % wsk action create Bj .. % wsk action create Bc ..
  48. 48. 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
  49. 49. 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
  50. 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 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
  51. 51. T A Bj Rj cloud debugging broker (wskdb) T2 Bc C Rc developer laptop
  52. 52. T A Bj Rj cloud debugging broker (wskdb) T2 Bc C Rc developer laptop
  53. 53. T A Bj Rj cloud debugging broker (wskdb) T2 Bc C Rc developer laptop
  54. 54. T A Bj Rj cloud debugging broker (wskdb) T2 Bc C Rc developer laptop
  55. 55. T A Bj Rj cloud debugging broker (wskdb) T2 Bc C Rc developer laptop
  56. 56. 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
  57. 57. Future directions What’s coming next?
  58. 58. What are you going to do next?
  59. 59. What are you going to do next?
  60. 60. Backup
  61. 61. Edge VMEdge VMEdge VM Edge VMEdge VMMaster VM Edge VMEdge VMSlave VM REST client CLI UI core runtime foundation: virtual machines (IaaS, vagrant, …) Why virtual machines? • direct access to host OS for some container functions • OS support for security, networking, resource control • infrastructure, stability, tools

×