Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Serverless Backends and APIs using Swift and Apache OpenWhisk

Serverless Backends and APIs using Swift and Apache OpenWhisk

Do you want to build backend applications using Swift but don’t want to manage computing infrastructure to run those applications in the cloud? Enter serverless cloud platforms…

Serverless platforms allow developers to push code, rather than VMs, into the cloud. The platforms allow you to connect external event sources like API requests or message queues to functions in your code. As events occur, your code is instantiated and executed to process each request. Developers are only billed for the milliseconds needed to process each request.

In this workshop, developers will learn how to build backends and APIs using Swift on “serverless” cloud platforms. We’ll work through getting started with Apache OpenWhisk, an open-source serverless cloud platform that supports Swift natively. Developers will learn how to create simple serverless swift functions, before building up to more complicated applications and architectures. People leaving the session will have all the skills to be able to build scalable microservices on serverless cloud platforms using Swift.

Dad87927739931f134c5b1242e3d04bc?s=128

James Thomas

March 13, 2018
Tweet

Transcript

  1. IBM and Business Partner Use Only l Fast Start 2018

    @thomasj James Thomas
 Developer Advocate, IBM ☁ Serverless Backends and APIs with
 Swift and Apache OpenWhisk © 2017 IBM Corporation l Interconnect 2017
  2. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Introduction 1. What is serverless aka FaaS? 2. Why is serverless better than a traditional approach? 3. What is Apache OpenWhisk & IBM Cloud Functions? 4. How does IBM Cloud Functions fit into our cloud ecosystem? 5. What is IBM Cloud Functions good for? 6. Who are our competitors? 7. Additional material 8. Hands-on workshop
  3. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Agenda 1. What is serverless aka FaaS? 2. Why is serverless better than a traditional approach? 3. What is IBM Cloud Functions fka OpenWhisk? 4. How does IBM Cloud Functions fit into our cloud ecosystem? 5. What is IBM Cloud Functions good for? 6. Who are our competitors? 7. Additional material 8. Hands-on workshop
  4. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions What is serverless aka FaaS? Runs code only on-demand on a per-request basis Serverless deployment & operations model VM No servers Just code
  5. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions What is serverless aka FaaS? Runs code only on-demand on a per-request basis
  6. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions What is serverless aka FaaS? Runs code only on-demand on a per-request basis Scales on a per-request basis
  7. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions What is serverless aka FaaS? Runs code only on-demand on a per-request basis Optimal utilization & granular pricing zz z time charged
  8. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Agenda 1. What is serverless aka FaaS? 2. Why is serverless better than a traditional approach? 3. What is IBM Cloud Functions fka OpenWhisk? 4. How does IBM Cloud Functions fit into our cloud ecosystem? 5. What is IBM Cloud Functions good for? 6. Who are our competitors? 7. Additional material 8. Hands-on workshop
  9. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Why is serverless better than a traditional approach? CF Container VM Application Process and Idle 2 Requests 1a Polling 1b Worry about scaling • When to scale? (mem-, cpu-, response time-, etc. driven?) • How fast can you scale? Worry about resiliency & cost • At least 2 processes for HA • Keep them running & healthy • Deployment in multiple regions Charged even when idling / not 100% utilized Continuous polling due to missing event programming model Traditional model Process and Idle
  10. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Trigger 1 OpenWhisk Engine 2 Pool of Actions Js Swift Java Python Docker Running Action Running Action Running Action 3 Scales inherently • One process per request No cost overhead for resiliency • No long running process to be made HA / multi-region Introduces event programming model Charges only for what is used • Only worry about code
 higher dev velocity, lower operational costs Serverless model Deploy actions within millisecs, run it, free up resources Why is serverless better than a traditional approach?
  11. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions 1. What is serverless aka FaaS? 2. Why is serverless better than a traditional approach? 3. What is Apache OpenWhisk & IBM Cloud Functions? 4. How does IBM Cloud Functions fit into our cloud ecosystem? 5. What is IBM Cloud Functions good for? 6. Who are our competitors? 7. Additional material 8. Hands-on workshop Agenda
  12. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions What is Apache OpenWhisk & IBM Cloud Fns? FaaS platform to execute code in response to events
  13. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Delivered as
 open-source via Apache openwhisk.org FaaS platform to execute code in response to events What is Apache OpenWhisk & IBM Cloud Fns?
  14. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Managed service on
 IBM Cloud bluemix.net/openwhisk FaaS platform to execute code in response to events What is Apache OpenWhisk & IBM Cloud Fns?
  15. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Supported Languages JS/NodeJS Swift Python Java Docker Go Haskell Scala . . . Multi- language Support Community Efforts … and more to come JS/NodeJS 8 Java Python 3 Swift 3 Docker / Binary Go … Scala What is Apache OpenWhisk & IBM Cloud Fns? PHP Rust Haskell
  16. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Non-blocking Blocking Periodic Support for different invocation models What is Apache OpenWhisk & IBM Cloud Fns?
  17. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Event Provider Open event emitter (consumer ecosystem) Open interface
 for event emitters What is Apache OpenWhisk & IBM Cloud Fns?
  18. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Event Provider Periodic IBM Cloudant Message Hub Mobile Push Github IBM App Connect What is Apache OpenWhisk & IBM Cloud Fns?
  19. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Supports higher-level programming constructs Chaining/ Sequencing Action 1 Action 2 Parameter Binding Default Name Default Parameters Default Value What is Apache OpenWhisk & IBM Cloud Fns?
  20. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Memory allocated (MB) Time executing (milliseconds) Instances executing simultaneously (count) Pricing model Time an action was running * memory allocated to action $0.000017 per GBs Free tier: 400000 GBs per month What is Apache OpenWhisk & IBM Cloud Fns?
  21. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Agenda 1. What is serverless aka FaaS? 2. Why is serverless better than a traditional approach? 3. What is IBM Cloud Functions fka OpenWhisk? 4. How does IBM Cloud Functions fit into our cloud ecosystem? 5. What is IBM Cloud Functions good for? 6. Who are our competitors? 7. Additional material 8. Hands-on workshop
  22. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions How does IBM Cloud Functions fit into our cloud ecosystem? Bare Metal Virtual Server 
 or VMware Container IBM Cloud Functions Cloud Foundry Performance & Control Speed Language/
 Framework “Serverless” / “Event Driven” Apps Open PaaS Environment Maximum Performance & Control Maximum Portability Portability Leverage Existing Images & Tools IBM Cloud Container Service | IBM Confidential | ©2017 IBM Corporation
  23. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Agenda 1. What is serverless aka FaaS? 2. Why is serverless better than a traditional approach? 3. What is IBM Cloud Functions fka OpenWhisk? 4. How does IBM Cloud Functions fit into our cloud ecosystem? 5. What is serverless good for? 6. Who are our competitors? 7. Additional material 8. Hands-on workshop
  24. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Volatile and/or event-driven workload that can be split in smaller short-running pieces. Suited for sporadic as well as heavy load scenarios. What is serverless good for?
  25. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions API Gateway support Allows to map API endpoints 
 to IBM Cloud Functions actions Serverless microservice APIs/backend Available for free, without limits Define Actions: getCostumer createCostumer
 deleteCostumer Define API Endpoints (URLs) and map to Actions Get: mydomain.com/…/customers Post: mydomain.com/…/customers
 Delete: mydomain.com/…/customers 1 2 What is serverless good for?
  26. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions getCostumer createCostumer
 deleteCostumer Easy to add and edit: Security (API key, API secret, OAuth validation, CORS) Rate-Limiting Map actions to API endpoints (OpenAPI Doc creation) Easy socialization (sharing, API key creation) Analytics (API calls, errors, response time) Test your API (API Explorer) Upload Swagger/OpenAPI Doc 3 2 1 What is serverless good for?
  27. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Swift Action IBM API Gateway Openwhisk API Hi! Outsource compute-intensive tasks to a powerful & scalable serverless platform and implement your actions even without changing the programming language. Swift Action Mobile backend What is serverless good for?
  28. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Data processing Openwhisk IBM Cloudant What is IBM Cloud Functions good for?
  29. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Data processing Openwhisk IBM Cloudant Ideally suited for working with multimedia data like audio, image and video data: Audio normalization Image rotation, sharpening, noise reduction or Thumbnail generation Image OCR’ing Video transcoding What is IBM Cloud Functions good for?
  30. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Cognitive Openwhisk IBM Cloudant What is IBM Cloud Functions good for?
  31. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Real-time Datastream Openwhisk IBM Message Hub IBM Cloudant Event processing/ Message Hub Managed Apache Kafka service for real- time build outs of data pipelines and streaming apps supports binary data What is IBM Cloud Functions good for?
  32. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Watson IoT Realtime Insights Trigger events based on IoT sensor data IOT Device 1 Weather Update Trigger Watson IOT Platform Realtime Insights rules 2 3 4 Trigger an Action IBM Cloud Functions What is IBM Cloud Functions good for?
  33. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions 1. What is serverless aka FaaS? 2. Why is serverless better than a traditional approach? 3. What is IBM Cloud Functions fka OpenWhisk? 4. How does IBM Cloud Functions fit into our cloud ecosystem? 5. What is IBM Cloud Functions good for? 6. Who are our competitors? 7. Additional material 8. Hands-on workshop Agenda
  34. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Other serverless platforms… Competitors Apache OpenWhisk is the only platform to support Swift natively
  35. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Agenda 1. What is serverless aka FaaS? 2. Why is serverless better than a traditional approach? 3. What is IBM Cloud Functions fka OpenWhisk? 4. How does IBM Cloud Functions fit into our cloud ecosystem? 5. What is IBM Cloud Functions good for? 6. Who are our competitors? 7. Additional material 8. Hands-on workshop
  36. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Commercial offering home: bluemix.net/openwhisk Open-source offering home: openwhisk.org Slack: slack.openwhisk.org Additional material Learn more
  37. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Github github.com/openwhisk Twitter twitter.com/openwhisk Medium medium.com/openwhisk Slideshare slideshare.net/OpenWhisk Youtube youtube.com/channel/ UCbzgShnQk8F43NKsvEYA1SA Learn more Learn more
  38. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Agenda 1. What is serverless aka FaaS? 2. Why is serverless better than a traditional approach? 3. What is IBM Cloud Functions fka OpenWhisk? 4. How does IBM Cloud Functions fit into our cloud ecosystem? 5. What is IBM Cloud Functions good for? 6. Who are our competitors? 7. Additional material 8. Hands-on workshop
  39. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions What you will learn Hands-on workshop 1. Setting up development environment 2. Basic concepts: Actions, Triggers, Rules, Packages 3. How to work with the IBM Cloud Functions CLI 4. How to work with the IBM Cloud Functions UI 5. Connecting actions to event sources. 6. Exposing actions as APIs using API Gateway. 7. How to work with additional tools
 … Serverless Framework 8. Building a Weather bot for Slack
  40. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Time to get started… Let’s go! Hands-on workshop
  41. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Important links Hands-on workshop Workshop materials:
 http://bit.ly/serverless-swift Follow Swift code examples
  42. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions Coming soon… Hands-on workshop Swift 4 + Codable support!
  43. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions
  44. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions
  45. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions More info… Hands-on workshop Try this out today…
 https://github.com/apache/ incubator-openwhisk-runtime-swift
  46. IBM and Business Partner Use Only l Fast Start 2018

    IBM Cloud Functions In case you want to follow or reach out… Mail: james.thomas@uk.ibm.com Twitter: @thomasj Slack: http://openwhisk.incubator.apache.org/slack.html Hands-on workshop