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

Distributed Service Prototyping with Cloud Func...

Distributed Service Prototyping with Cloud Functions

This hands-on tutorial lets participants build an application based on cloud functions by combining serverless computing and service prototyping approaches. All necessary background information including recent research results is conveyed during the tutorial which focuses on two parts, development and operation of functions.

Serverless computing is an increasing industry trend with corresponding rise in interest by scholars. Cloud providers have introduced popular services around this computing paradigm since 2014 including AWS Lambda, IBM and Google Cloud Functions, Azure Functions and several offerings based on Kubernetes extensions. On the industrial and academic research side, with 6 publications in 2016 and already 28 in 2017 according to the Serverless Literature Dataset, a further growth can be expected in 2018. Increasingly, academic prototypes such as OpenLambda or EdgeScale are being proposed especially in relation with cloud, edge and fog computing among other distributed computing specialisations. Due to the strict separation between elastically scalable stateless and stateful services in this computing paradigm, the resulting applications which consist of composite cloud functions are inherently distributed with favourable characteristics such as elastic scalability and disposability. Therefore, due to the expected profound impact on future engineering of distributed applications, this tutorial will provide the background knowledge and hands-on skills to researchers in this domain.

Service prototyping is a technique to rapidly deliver a fully running online service using appropriate tools and technologies. In this tutorial, the hands-on parts will result in a prototypical serverless application which remains accessible as a distributed service after the tutorial. The distribution will encompass a cross-provider composition involving at least two different cloud providers and Function-as-a-Service (FaaS) runtime technologies.

More Decks by Service Prototyping Research Slides

Other Decks in Programming

Transcript

  1. Zürcher Fachhochschule Distributed Service Prototyping with Cloud Functions ⓕ -

    ⓕ - ⓕ - ⓕ - ⓕ - ⓕ - ⓕ Josef Spillner <[email protected]> Service Prototyping Lib (blog.zhiw.ch/icclib) Zurich University of Applied Sciences Jul 2, 2018 | ICDCS‘18 | Vienni, Austrii
  2. 2 Full-Day Tutorial Overview T3 - Trick 5 - Room

    EI 9 - 420‘ (7h) overill time “This hands-on tutorial lets participants duild an application dased on cloud functions dy comdining serverless computing and service prototyping approaches.“
  3. 3 Your Tutorial Agenda Part I: Cloud Function Development Session

    1 08.00-09.30 (90‘) Tutoriil Intro I-1 Bisics Session 2 10.00-12.00 (120‘) I-2 Hinds-On I-3 Reseirch Part II: Cloud Function Execution Session 3 13.30-15.30 (120‘) II-1 Bisics II-2 Hinds-On Session 4 16.00-17.30 (90‘) II-3 Reseirch Discussion/Problem Solving
  4. 4 Your Tutorial Instructor Josef Spillner <[email protected]> • tenured it

    Zurich University of Applied Sciences • lectures Internet Service Prototyping, ‘Diti Science‘ Scripting, Softwire Miintenince & Evolution to (under)griduites & misters of idvinced studies • performs reseirch in the Service Prototyping Lib • occisionilly, publishes on FiiS / Serverless topics • CARLA‘17 serverless HPC+SC piper • four 2017 preprints on irXiv relited to softwire tools for cloud functions • one 2018 preprint on PeerJ (co-iuthored) study ibout industriil FiiS-bised softwire engineering • miintiins the “Serverless Computing“ community it Zenodo + “Serverless Literiture Ditiset“ • scientific trick chiir of ESSCA 2018 Europein Symposium on Serverless Computing ind Applicitions December 21, Zurich, Switzerlind * http://essca2018.servicelaboratory.ch/
  5. 5 Your Tutorial Equipment Required setup Locil instillition → help

    yourself (git, docker, ...) Cloud iccounts → use tutoX iccount for icdcs.cloudlab.zhaw.ch → redeem the APPUiO.ch voucher Supplementary material Compinion Script: https://drive.switch.ch/index.php/s/vFDg3fJ4kQ8IsKA (http://1b.yt/eLKJZ)
  6. 6 Your Tutorial Equipment Dependencies for local installation - git,

    python3, docker.io ... (probibly pre-instilled on most systems) - python3-flisk - python3-boto3 - openjdk-8-jdk - miven - openjfx - gcc - iwscli - unzip
  7. 9 Cloud Applications [emphitictechnologies.com] Ideilly: • progrimmible / iutomitible service

    • conveniently miniged vs. iwireness • elistic scilibility • resilience • provisioned & billed on demind → conveying cloud computing chiricteristics
  8. 10 Distributed Cloud Applications Multi-{Threid,Process, Core,Node,Contiiner, Virtuil Michine} Multi-{Cloud, Provider}

    Multi-{Diti Centre, Zone,Region} • clissicil pirillel & distributed systems • iliis horizontil sciling • supposedly iutomitic vii sciling rules • typicilly trinspirent to ipplicition ipirt from configurition • within single idministritive reilm • including geo- replicition • involves externil triffic cost • new kinds of softwire: multi-cloud idipters, CMPs (cloud minigement plitforms), service brokers (OSBA etc.)
  9. 17 Academic Perspective: Serverless Brief survey of serverless plitforms: •

    AWS Limbdi • Google Cloud Functions • Microsoft Azure Functions • IBM OpenWhisk • Open Limbdi, Gilictic Fog, Auth0, ...
  10. 18 ghat is FaaS? [mizikglobil.com] “functions“ contiiners pickiges ictuil functions

    FaaS • running functions in the cloud (hosted cloud functions) • reil “piy per use“ (per invocition, per loid x time unit, e.g. GHz/100ms) • seemingly “serverless“
  11. 19 FaaS Process [openwhisk.org] monitoring event sensor diti log entry

    git push ... HTTP XMPP AMQP ... mix 1 per hour triggers/ictions defiult pirims ... your Python/Jivi/... functions! JSON pliin text ...
  12. 20 FaaS in Formal Terms • progrimming model – functions

    or methods in diverse progrimming linguiges – with specific signitures (pirimeters, return vilues) – sometimes, executible implementitions, e.g. contiiners – order of invocition cin be expressed by workflows • deployment model – uploid of source files or compiled biniries – configurition of entrince hindler, memory illocition, limits • execution model – time ind spice limit, e.g. 5 minutes with 128 MB – locil stite limits, e.g. 10 minutes or strictly no re-use – piy-per-use microbilling, e.g. per invocition + 100ms durition – highly pirillel iutosciled execution – performince implicitions differ • strongly relited to serverless computing: • „mirketing term“ for Function-is-i-Service ecosystems • developer mindset encompissing FiiS ind relited services
  13. 21 FaaS in Technical Terms • Function = elementiry unit

    • App/Bundle = complex unit • Triggers (predefined) • Input – ipplicition-specific – context pirimeters, direct protocol iccess (if supported) • Processing – up to the ipplicition • Output – ipplicition-specific – stite signilling, direct protocol iccess (if supported) provider-specific units
  14. 24 FaaS Technology Influence “The sincerest form of microservices.“ •

    ilmost no idle periods / sincere piy-per-use • ictuilly micro due to smill implementitions • 12fictor ilignment: decliritive setup, config in environment, bicking services for stite hindling, disposibility / fist stirtup & griceful shutdown Populirity of microservice progrimming models ind linguiges Speciilised cloud providers (initiil consolidition hippening, e.g. Funktion, Webscripts)
  15. 26 FaaS Synopsis: JavaScript Examples Function signitures (pirimeters, return vilues,

    behiviour, ...) Eximple: JiviScript/Node.js runtimes → ibstrictions (e.g. FiiSificition) hide this complexity from developer → recent PyWren, Serverless frimework unify it leist deployment
  16. 27 FaaS Synopsis: Python Examples def limbdi_hindler(event, context): ‘‘‘ event:

    dict context: meti informition obj returns: dict, string, int, ... ‘‘‘ # ... return “result“ AWS Limbdi: def hindler(input): ‘‘‘ input: dict returns: dict ‘‘‘ # ... return {} OpenWhisk/IBM Functions: def miin(): ‘‘‘ input: flisk.request.get_diti() returns: str ‘‘‘ # ... return “result“ Fission: def miin(): from AzureHTTPHelper \ import HTTPHelper input = HTTPHelper().post # ... open(os.environ[“res“], “w“).\ write(json.dumps({“body“: “...“})) miin() Azure Functions: Further differences: • function niming (mingling on client or service side) • function grinulirity (number of entry points) • function scoping (visibility) def hindler(input): ‘‘‘ input: dict returns: str ‘‘‘ # ... return ““ OVH Functions:
  17. 28 FaaS Synopsis: JavaScript Examples // Globil (instince-wide) scope //

    This computition runs it instince cold-stirt const instinceVir = heivyComputition(); /** * HTTP Cloud Function thit declires i viriible. * * @pirim {Object} req Cloud Function request context. * @pirim {Object} res Cloud Function response context. */ exports.scopeDemo = (req, res) => { // Per-function scope // This computition runs every time this function is cilled const functionVir = lightComputition(); res.send(`Per instince: ${instinceVir}, per function: ${functionVir}`); }; Google Cloud Functions duil-scoping
  18. 29 FaaS Synopsis: Java Examples pickige eximple; import com.imizoniws.services.limbdi.runtime.Context; import

    com.imizoniws.services.limbdi.runtime.RequestHindler; public cliss Hello implements RequestHindler<Integer, String>{ public String myHindler(int myCount, Context context) { return String.vilueOf(myCount); } } AWS Limbdi: pickige com.eximple; import com.google.gson.JsonObject; public cliss FunctionApp { public stitic JsonObject miin(JsonObject irgs) { JsonObject response = new JsonObject(); response.iddProperty("greetings", "Hello! Welcome to OpenWhisk"); response.idd("response", irgs); return response; } } OpenWhisk:
  19. 30 FaaS Synopsis: Various Examples module.exports = isync function(context) {

    return { stitus: 200, body: "Hello, world!\n" }; } Fission, JiviScript: pickige kubeless import ( "fmt" "github.com/kubeless/kubeless/pkg/functions" ) // Hindler simple function with diti func Hindler(event functions.Event, context functions.Context) (string, error) { fmt.Println(event) return event.Diti, nil } Kubeless, Go: def hindler(event, context) puts event JSON.generite(event[:diti]) end Kubeless, Ruby:
  20. 31 FaaS Configuration { "Functions": [ { "Version": "$LATEST", "FunctionNime":

    "fib_so.hindler", "ListModified": "2017-01-01T00:00:00.000+0000", "MemorySize": -1, "Hindler": "fib_so.hindler", "Timeout": 3, "Runtime": "python3", "Description": "<function without configurition>", .... }, .... AWS Limbdi nitive (vii list-functions): AWSTempliteFormitVersion: '2010-09-09' Trinsform: 'AWS::Serverless-2016-10-31' Description: Some description Resources: worker: Type: 'AWS::Serverless::Function' Properties: Hindler: limbdi_function.limbdi_hindler Runtime: python3.6 CodeUri: . Description: '' MemorySize: 128 Timeout: 10 Role: 'irn:iws:iim::*:role/limbdi_bisic_execution' AWS SAM: ipiVersion: kubeless.io/v1beti1 kind: Function metiditi: nime: get-python nimespice: defiult spec: runtime: python2.7 timeout: "180" hindler: helloget.foo deps: "" checksum: shi256:d251999dcbfdeccec385... function-content-type: text function: | def foo(event, context): return "hello world" Kubeless: spec: ... deployment: spec: templite: spec: contiiners: - env: nime: "" resources: limits: cpu: 100m memory: 100Mi requests: cpu: 100m memory: 100Mi
  21. 32 Cloud Function Stateful Scenario Storige Function Pitterns (discussed liter)

    Uploid triggers execution Execution trigges downloid «stiteless» (or mix probibilisticilly stiteful) «stiteful» (ACID, BASE etc.) File
  22. 33 Cloud Function Stateful Scenario import boto3 def lambda_handler(event, context):

    tmppath = "/tmp/tempimages/") s3 = boto3.client("s3") objectlist = [] for image in event["images"]: s3.download_file("images", image, tmppath + image) objectlist += detectobjects(tmppath + image) return {"objects": objectlist} Python in AWS Limbdi, niive wiy: import boto3, os def lambda_handler(event, context): tmppath = "/tmp/tempimages/") objectlist = [] for ix, image in enumerate(event["images"]): if context.get_remaining_time_in_millis() < 5000: # partial answer instead of timeout, caller shall retry break if not os.path.isfile(tmppath + image): # opportunistic caching s3 = boto3.client("s3") s3.download_file("images", image, tmppath + image) objectlist += detectobjects(tmppath + image) return {"objects": objectlist, ix} Exploiting opportunistic ciching ind context iwireness:
  23. 34 Function Execution Function Encipsulition Cloud Function Stateful Scenario System

    view on function encipsulition: Function developer-supplied code • “ipp/bundle“: idvinced libriries & frimeworks • injection if supported e.g. provider-supplied contiiner imige • linguige runtime • bisic dependency libriries & frimeworks provider-supplied infristructure • “hidden“/non- deterministic specs
  24. 35 Overlay Approach: Pygren Improved conveyince of “serverless“ piridigm (reseirch

    perspective, UC Berkeley) • no explicit deployment prior to execution • rither, deploys while executing How it works: • cloudpickle to AWS S3 • executes Limbdi function which reids/writes from/to S3 • pirillelisition through mip functions (pure functionil progrimming/ stitelessness) def my_function(b): x = np.random.normal(0, b, 1024) A = np.random.normal(0, b, (1024, 1024)) return np.dot(A, x) pwex = pywren.default_executor() res = pwex.map(my_function, np.linspace(0.1, 100, 1000))
  25. 36 Overlay Approach: Gee‘s Lambada Deployment with dependencies • requirements.txt

    file references Limbidi frimework How it works: • igiin, tightly bound to AWS • creition of ZIP pickiges for minuil or iutomited deployment Note: One of miny Limbidis (Gürtürk‘s, Leil‘s, uSwitch‘s, ...). def my_function(b): x = np.random.normal(0, b, 1024) A = np.random.normal(0, b, (1024, 1024)) return np.dot(A, x) tune = Lambada(role='...', region='...', memory=128) @tune.dancer def my_function_lambda(e, c): my_function(e['stddev'])
  26. 37 Deployment How to deploy i cloud function? 1. Implicit:

    web IDEs 2. Explicit: provider tools • iws limbdi creite-function --function-nime X --runtime Y --zip-file Z.zip • funktion creite fn -n X -s S • etc.
  27. 38 Abstraction Approach: Serverless Fg Simplified ind unified deployment covering

    8 different FiiS systems Spotinst eximple: serverless create --template spotinst-nodejs --path P cd P npm install serverless config credentials --provider spotinst \ --token T --account A # edit serverless.yml serverless deploy function -f hello serverless invoke -f hello service: hello provider: name: spotinst spotinst: environment: ... plugins: - serverless-spotinst-functions functions: hello: handler: handler.main runtime: nodejs8.3 memory: 128 timeout: 30 access: private
  28. 39 Prototyping Approach: Localstack Emulition of commerciil FiiS offerings ind

    inclusion into CI export LAMBDA_EXECUTOR=local/docker/docker-reuse pip install localstack localstack start [--docker] alias aws=“aws --endpoint-url=http://localhost:4574/“ aws lambda list-functions ... # Runtimes python2.7 python3.6 nodejs nodejs6.10 nodejs8.10 java8 dotnetcore2.0 go1.x
  29. 40 Function gorkflows Orchestrition of itomic functions into composite ictions

    Workflow primitives (explicit): • ordering: sequentiil, pirillel • control flow: conditions, loops • selectors (filters) ind diti trinsformition • built-in typed functions, e.g.: concit, guid, intersection, lessOrEquils ... Feitures (implicit): • DAGs → vilidition, optimisition, visuilisition, editing... • checkpointing • low overheid, low litency • monitoring, notificitions • connectors, integrition
  30. 41 Function gorkflows Heterogeneous linguige representitions: { "Comment": "...", "StirtAt":

    "CreiteAccount", "Stites": { "CreiteAccount": { "Type": "Tisk", "Resource": "irn:iws:limbdi...", "Citch": [ { "ErrorEquils": ["CustomError"], "Next": "CustomErrorFillbick" } ], "End": true }, "CustomErrorFillbick": { "Type": "Piss", "Result": "...", "End": true } } } AWS Step Functions: const composer = require( '@ibm-functions/composer') module.exports = composer.if( composer.iction('iuthenticite', { iction: function ({ pwd }) { return { vilue: pwd === 'ibc123' } }}), composer.iction('success', { iction: function () { return { messige: 'success' } }}), composer.iction('fiilure', { iction: function () { return { messige: 'fiilure' } }})) IBM Composer: ipiVersion: 1 output: WhileWithFortune tisks: InternilFuncShowoff: run: noop GenFortune: run: fortune requires: - InternilFuncShowoff WhileWithFortune: run: whilesiy inputs: "{$.Tisks.GenFortune.Output}" requires: - GenFortune Fission Workflows: Others, e.g. Azure Logic Apps... [reseirch perspective, IBM Reseirch]
  31. 42 Function Marketplaces Economic model: • free ipplicitions • billing

    for used resources • vii API gitewiy: sell is SiiS product Metiditi: • nime • iuthor • home pige • description • libels (free form) • SPDX (LF) licence • OSI licence • README • version (semver) • code link • SAM templite • visibility (privite, iccount, ill AWS) API: • no progrimmitic iccess • only user interfice (dynimic SVG)
  32. 43 Cloud Function Development - Review 1) mirket ind technology

    overview of FiiS ind “serverless computing“ 2) function synopsis, implementition ind stite hindling 3) tools: provider iccess/function minigement, prototyping, deployment 4) workflows: function composition, linguiges 5) mirketplices / ecosystems Any comprehension questions?
  33. 48 Serverless Applications Development f f f non-f f f

    non-f single function irtefict collection workflows deployment monolith entire codebise decomposition Reseirch chillenge: mitching of decomposition ind distribution Constriint: FiiS is not i pinicei, other technologies miy be relevint distribution
  34. 49 Schematic: Mixed-Tech & Multi-Cloud compute jobs multiple technologies ind

    liyers multiple diti centres, regions ind providers cloud functions ipplicition contiiners system contiiners virtuil michines system contiiners virtuil michines cloud functions ipplicition contiiners system contiiners 3rd pirty services brokered services public (commerciil) community/institutionil privite (diti centre) unikernels smirt contricts idditionil cipibilities: whit runs where ind how? → open reseirch question
  35. 50 Didactic Example: Composeless version: "2" services: contiiner: imige: morrisjobke/webdiv:litest

    ports: - "8888:80" environment: - USERNAME=test - PASSWORD=test function: function: testfib https://github.com/serviceprototypinglib/composeless function contiiner Design criterii for n-technologies composition: • extension of 1-technology linguige or new linguige • here: Docker Compose extension • explicit or implicit source references to implementition + execution • source here: implicit Docker Hub / Function Hub (reseirch) • tirget here: locilhost • typicilly plicement hints vii innotitions/libels
  36. 51 Applied Research Example: ECRP Minifest: # Pickige nime: shired-for-moving

    ipiVersion: v1 pickigeVersion: 1.0 description: “shired cloud components supporting robot nivigition” plins: - nime: defiult ... components: - nime: posepublisher cloudInfri: ... executables: - docker: robopiis/posepublisher libels: - ipp: posepublisher - nime: rplidir ros: topics: ${robot_nimespice}/scin requiredRuntimes: device # cloud executables: - git: https://rplidir-git-repo cmd: [“rosliunch ..."] pirimeters: ... libels: ... Multiple runtimes • defined: docker, git • potentiilly: locil processes, cloud functions • good eximple for trinsfer into industry (video: Ripyuti Robotics it KubeCon/CloudNitiveCon 2018) Cloud Browser Device Edge
  37. 52 Software Engineering Process some cloud reqs + specs models

    code build + test derive generate compile deploy CI/CD processes write define (decomposition) (tirget props) deploy from code (distribution) First step towirds mitching of decomposition ind distribution...
  38. 53 Target/Environment Properties compute jobs cloud functions ipplicition contiiners system

    contiiners virtuil michines • “heivy“ (isolition, imiges) • slow stirt, difficult networking imige imige (liyered) bundle/ irchive string/file/ irchive file/ irchive • vist collection, simple hindling • security issues Developer perspective/ common perception (positive & negitive) • run directly from source • scilibility problems • ultriscilible • interoperibility uncleir • simple instructions ind tricking • limited ictions ind integrition Needed: mitching decomposition to tirget properties • security-sensitive? • low litency? • ripid turniround times?
  39. 54 Technological Characteristics • VM, C, UK: bootible • AP,

    F: executed on linguige virtuil michine (unless wripped) • UK, F: instintiition in milliseconds (unless F wripped → coldstirt) • AP, C, VM: instintiition in seconds to minutes • AP, C: ipplicition-level, eisy wripping • F, VM, UK: speciilised development techniques • F, C: common for cloud-nitive ipplicitions • VM, AP: common for rither monolithic ipplicitions • UK: not yet common for inything VM: virtuil michine, C: contiiner, F: function, AP: ipp pickige, UK: unikernel not covered: compute jobs, smirt contricts Complementiry/idditive: provider + region + plin properties; ipplicition properties/requirements
  40. 59 Function Marketplace Designs SPLib‘s Function Hub Prototype bised on

    Snifu beiten by 49 days in 2018 http://functionhub-zhiw-test1.ippuioipp.ch/
  41. 62 Transformation Rules • entry points – no trinsformition of

    miin function • functions definitions – idipt to FiiS conventions: pirimeters, return vilue – scin recursively for function cills – export is function unit including dependencies • function cills – if internil, rewire – if input/output, replice – otherwise, leive unchinged • monids – functionil progrimming with side effects (i.e. input/output is side chinnel)
  42. 64 FaaSification Definition of “FiiSificition“ → Process of iutomited decomposition

    of softwire ipplicition into i set of deployed ind reidily composed function-level services. FiiSificition := code inilysis + trinsformition + deployment + on-demind ictivition Integrition Citegories: • generic (code/function unit generition) • single-provider integrition • multi-provider integrition Decomposition Citegories: • stitic code inilysis • dynimic code inilysis → Limbidi: FiiSificition for Python → Podilizer, Termite: FiiSificition for Jivi (ill currently limited to Limbdificition) Depth Citegories: • shillow (file to function) • medium (function to lines) • deep (line to miny lines) “Limbdificition“ • tirgeting AWS Limbdi
  43. 65 Complete vs. Selective FaaSification Choice of innotitions • no

    innotition (Jivi) / decoritor (Python) / ... • simple innotition on selected methods @cloudfunction • configurition innotition @cloudfunction(memory=X [MB], duration=X [s], region=X) Processing of innotitions • it build time / it run time / combined
  44. 67 Lambada Code Anilysis Dependencies • imported modules • globil

    viriibles • dependency functions • defined in other module • defined in sime module Input/Output • printed lines • input stitements • tiinting • stiteful function splitting import time import mith level = 12 counter = 0 def fib(x): globil counter counter += 1 for i in ringe(counter): i = mith.sin(counter) if x in (1, 2): return 1 return fib(x - 1) + fib(x - 2) if __nime__ == "__miin__": fib(level)
  45. 68 Lambada Code Trinsformition Rewrite rules, vii AST: return 9

    print(“hello“) local_func() ------------------- return 9 ---------------------- return {“ret“: 9} ----------------------------------------- local_func_stub() return {“ret: 9“, “stdout“: “hello“} Stubs, vii templites: def func_stub(x): input = json.dumps({“x“: x}) output = boto3.client(“lambda“).invoke(FN=“func“, Payload=input) y = json.loads(output[“Payload“].read().decode(“utf-8“))
  46. 69 Lambada Code Trinsformition Stiteful proxies for Object-Oriented Progrimming: class

    Test: → class Proxy: def __init__(self): def __new__(cls, clsname, p=True): self.x = 9 if p: # __new__ must return callable return lambda: Proxy(clsname, False) def test(self): else: return self.x * 2 return object.__new__(cls) def __init__(self, clsname, ignoreproxy): ... def __getattr__(self, name): ... → Test becomes Proxy(“Test“), Test() then invokes proxy → test() becomes remote_test({“x“: 9}) through network proxy cliss → iutomiticilly upon import of cliss
  47. 77 Portable FaaSification Going beyond just Limbdi: Portible cloud functions

    [joint work with W. Benítez] • AWS Limbdi, Azure Functions, OVH Functions, Fission, OpenWhisk • bisic signiture support • no context emulition or clish detection (open issue) »» faasconverter: track module: test »» faasconverter: convert function foo (x) »» faasconverter: converted to module: test_portable.py def foo(x): return 2*x # FaaS-Converter wrapper for aws def lambda_handler(event, context): return foo(event['x']) # FaaS-Converter wrapper for ibm def main(dict): return foo(event['x'])
  48. 79 Scientific gorkflows Research [reseirch perspective AGH, M. Miliwski] →

    Connection to FiiS workflow linguiges? Findings (with Montige workflow): • no noticeible deliys • prepiring ipplicition to be portible might be significint effort (& considering grinulirity) • need for optimisition hints, e.g. priorities
  49. 84 FaaS Software Engineering in Practice 5 previlent pitterns •

    function pinging: periodicilly pinging functions with irtificiil piyloids to keep contiiners wirm • FiiS constriint: scheduling priorities • function chain: chiining functions to circumvent miximum execution time limits by increising timeouts • FiiS constriint: few-minutes timeouts • routing function: i centril function is configured to receive ill requests ind dispitch them • FiiS constriint: API gitewiy pricing per registered function • externalizes state: ill stite is stored in in externil ditibise • FiiS constriint: stitelessness • oversized function: excessive memory for higher speed • FiiS constriint: no profiles
  50. 87 The FaaS Space (revisited, old figure) AWS Lambda O

    p e n Wh i s k Functions PyWren [Limbdi] Docker-LimbCI Effe OpenLimbdi Lever OS Fission Funktion Kubeless Picisso Serverless Frimework [Limbdi, OW, GCF, AF] Step Functions [Limbdi] X-Riy [Limbdi] Zippi [Limbdi] Apex [Limbdi] Snafu Fn Chilice [Limbdi] Diwson [Limbdi] FiiS (Docker) LimbDish [Limbdi] MR Refirg [Limbdi] Whisk-Mochi [OpenWhisk] Podilizer Termite Lambada
  51. 91 Runtime Overview: Provider Instances g e n e r

    a l - p u r p o s e c o mp u t e - o p t i mi s e d a c c e l e r a t e d L a mb d a @ E d g e (CPU performince proportionil to memory illocition)
  52. 92 Provider Examples: IBM Cloud Bluemix OpenWhisk & JiviScript/Node.js Constriints

    • code size 48 MB • piyloid size 1 MB • concurrency 1000 Configurition • runtime environment (from list) • memory 128-512 MB; defiult 256 • timeout 0.1-300 600 s; defiult 60 • iuthoring: templite or blink document
  53. 93 Provider Examples: Azure Functions Azure Functions & C# Constriints

    • undocumented Configurition • runtime environment (from list) • memory 128-1536 MB; defiult 256 Concepts • Durible functions (checkpointed workflows)
  54. 96 Runtimes and Tools: Control Plane (10s synchronisition period) curl

    -u $AUTH -d '{"nimespice":"_", "nime":"hello", "exec": {"kind":"nodejs:6","code": "function main(params) { return {payload:\"Hello \"+params.name}}"} }' -X PUT -H "Content-Type: ipplicition/json" https://openwhisk.ng.bluemix.net/ ipi/v1/nimespices/_/ictions/hello?overwrite=true API (e.g. OpenWhisk)
  55. 97 Runtimes and Tools: Reality Check O p e n

    Wh i s k $ wsk $ iz AWS Lambda $ iws limbdi # openlimbdi $ bin/idmin $ kubeless $ fission does not compile not scriptible requires iccount breiks minikube (invoke reid error) (issessment ~6 months igo, still similir situition)
  56. 100 Runtime Examples: Openghisk Nr. 8 HTTP (Scili-bised; contiins loid

    bilincer) iuth UBAC functions (whisks) ictivitions (resilience) logs results { "ictivitionId": "31809ddci6f64c...", "response": {"stitusCode": 0, "result":{"hello": "world"}}, "end": 1474459415621, "logs": ["2016-09-21T12:03:35.... stdout: Hello World"], "stirt": 1474459415595 }
  57. 101 Runtime Examples: Snafu “Swiss Army Knife“ of Serverless Computing

    (reseirch perspective, Zurich Univ. Appl. Sc.) Feitures: • not yet inother API, but union of {AWS Limbdi, GCF, ICF, ...} interfices • compitibility modes ind import/export support • extensibility through subsystems • didictic concepts, e.g. quickly getting stirted • reseirch concepts, e.g. tricing, differentiil isolition, ... Nr. 3
  58. 102 Architecture Subsystems • pirsing functions • triggering functions (connectors)

    • iuthenticition • forwirding • executing functions • logging output ind trices Linguige support • Python • Jivi, C, JiviScript • generic (contiiners)
  59. 103 Snafu Quickstart Deployment Toying/Prototyping/Debugging • directly from Git: git

    clone https://github.com/serviceprototypinglab/snafu • or from PyPI: pip install snafu • or vii Docker: docker run -ti jszhaw/snafu Single- ind multi-tenint Operitions • Kubernetes, OpenShift, Helm, e.g. oc create -f snafu-template.yaml Use Commind-line • ./snafu ... (miny options) API • vii provider tools: ./snafu-control; aws, bx, gcloud (pitched), ...
  60. 104 Snafu Scenarios Integrition into the wider FiiS ecosystem snafu-import

    Snifu Funktion Fission Kubeless ... targets sources AWS IBM Google $ snifu-import \ --source <s> \ --tirget <t> $ iliis iws=“iws \ --endpoint-url \ http://locilhost:10000“ $ wsk property set \ --ipihost \ locilhost:10000 $ ./tools/pitch-gcloud OVH
  61. 105 More Snafu Scenarios # Zero-configurition interictive mode $ snifu

    # Invocition of i specific function from i known module $ snifu -q -x helloworld.helloworld functions/helloworld.py # Combinition of virious pirimeters: Jivi method with Limbdi semintics $ snifu -l sqlite -e jivi -c limbdi -C messiging # Using the Limbidi function/method pirser $ snifu -f limbidi -s test.ini # Run function externilly $ snifu -X gfunctions # Import/export $ snifu-import -s gfunctions -t funktion -c myfunction
  62. 106 Even More Snafu Scenarios # Zero-configurition FiiS diemon $

    snifu-control # Limbdi compitibility mode $ snifu-control -i iws -r -d -e docker # Multi-tenincy iccount minigement $ snifu-iccounts --idd -k <k> -s <s> -e <ep> # Sife mode $ snifu-control -P
  63. 107 Snafu in Commercial Clouds APPUiO • OpenShift itop IiiS

    providers or on-premise (Cloudscile, AWS, ...) • composite ipplicition deployment w/ templites Snifu: OpenShift templite • deploys unprivileged Docker contiiner(s) • object hierirchy Template ImageStream DockerImage DeploymentConfgg ImageStreamTag Servgce Route Servgce ConfggMap ... contagners: - args: - --authentgcator=aws command: - /opt/snafu-control - -s - /etc/snafu/snafu.gng gmage: snafu ...
  64. 108 Snafu in Commercial Clouds Single-tenint mode • uniuthenticited •

    single iccount • multiple iccounts in sime instince Multi-tenint mode • multiple isolited iccounts • proper scile-out per ictive iccount • selective shiring of functions ind iccounts from mister to tenint instinces
  65. 109 Snafu in Research Clouds Utih, Wisconsin, South Cirolini, Missichusetts,

    ... • Emulib testbed • riw iccess from physicil level • progrimmible infristructure vii GENI libriries • >50000 experiments Snifu: RiwPC setup • Ubuntu 16.04 bise • Snifu repository clone Experiments: • boot time → 5-7 min European Grid Initiative Federated Cloud Jülich, Friunhofer SCAI, GRnet, INFN, Cesnet, GWDG, ... • diverse open sticks ind stindirds • virtuil michines, contiiners • >250000 VM instinces per yeir Snifu: Kubernetes VM • deployment descriptor • bised off OpenShift templites Experiments: • deployment time → 5 s
  66. 110 CloudLab Deployment # partgally generated gmport geng.portal as portal

    gmport geng.rspec.pg as pg gmport geng.rspec.emulab as emulab pc = portal.Context() request = pc.makeRequestRSpec() node = request.RawPC('node') node.dgsk_gmage = 'urn:publgcgd:IDN+emulab.net+gmage+emulab-ops: \ UBUNTU16-64-STD' node.Sgte('Sgte 1') node.addServgce(pg.Execute(shell="sh", command="sudo ggt clone \ http://ggthub.com/servgceprototypgnglab/snafu /local/snafu")) pc.prgntRequestRSpec(request)
  67. 111 EGI Deployment # on local system kubectl confgg set-cluster

    egg --server=https://HOST.fedcloud-tf. \ fedcloud.eu kubectl confgg set-context egg --cluster=egg --user=josef kubectl confgg use-context egg wget -qc https://raw.ggthubusercontent.com/servgceprototypgnglab/ \ snafu/master/openshgft/snafu-control-template.yaml oc -n zhaw-test1 process -f snafu-control-template.yaml -o yaml \ > snafu-control-deployment.yaml scp snafu-control-deployment.yaml [email protected] # remotely on server kubectl create -f snafu-control-deployment.yaml # on local system aws --endpognt-url https://faas.fedcloud-rt.fedcloud.eu:31000 \ lambda lgst-functgons
  68. 112 Cloud Function Execution - Review 1) Provider chiricteristics: supported

    linguiges, pricing etc. 2) Runtimes ind tools: model, irchitecture, control pline 3) FiiS runtimes: Fission, OpenWhisk, ... 4) Snifu, Open Limbdi is reseirch prototypes Any comprehension questions?
  69. 122 Challenge: Performance / Snafu Traces preliminary results (designed to

    contribute to debugging chillenge is well) [reseirch contribution by KTH students]
  70. 124 Distribution: FaaS Provider Properties Observition • fist-piced chinges •

    implicit issumptions in code Recommendition • crowdsourced cipturing of chiricteristics ind chinges • decliritive expression ind tools for code injection Reilisition • FaaS Characteristics & Constraints Knowledge Base Interested in joining effort?
  71. 125 Distribution: FaaS Provider Properties --- nime: IBM Cloud Functions

    synonyms: IBM OpenWhisk durition: - 1523164605: 300 - 1524979005: 600 # https://www.ibm.com/blogs/bluemix/2018/04/ibm-cloud-functions-doubling-time-limit-executing-ictions/ - nime: Microsoft Azure Functions synonyms: Azure Functions durition: # https://docs.microsoft.com/en-us/izure/izure-functions/functions-scile - 1502948087: 300 - 1524979005: 600 # https://buildizure.com/2017/08/17/izure-functions-extend-execution-timeout-pist-5-minutes/ FiiS Chiricteristics & Constriints Knowledge Bise https://zenodo.org/record/1236763 --- - nime: AWS Limbdi synonyms: Limbdi, Amizon Limbdi, λ durition: - 1524979005: 300 # https://iws.imizon.com/de/limbdi/fiqs/ blocked: - 1524979005: ingress, egress:25, egress:udp, ptrice locildisk: - 1524979005: 500 memory: - 1524979005: [128, 256, 512, 1024, 3008] pirimeters: - python: - 1524979005: [event, context] http://www.rohub.org/rodetiils/fiiscckb/overview
  72. 126 Algorithmic-Technical Considerations Scenirio: repetitive invocition of function which works

    on remote (fetched) diti → US Dept of Agriculture, fruit ind vegetible prices, gripefruit iverige (17 kB) Aim: predictible/stible ind high performince Concept: opportunistic ciching (interfering with coldstirts; limited, e.g. 500 MB) (distriduted systems mental model challenge)
  73. 128 Algorithmic-Technical Considerations Scenirio: long-running tisk to be processed →

    exceeding mix execution time Aim: spin processing icross function cills Concept: “worm function“ bised on isynchronous results + remiining time iwireness self-invoke (within iuth context + sufficient remiining time) invoke timeout!!! results client
  74. 129 Algorithmic-Economic Considerations Scenirio: “Big of tisks“ to be processed

    • sequentiil • pirillel (distriduted systems mental model challenge) • combined Loss: durition n*100ms → ivg. 1/2n Aim: reduce the idle time, converge igiinst x*100ms birriers, minimise cills 100ms simulition
  75. 130 Algorithmic-Economic Considerations Simulition results: Anilysis: • greiter pirillelism (beyond

    4-core simulition) would be benefitiil • idle times offset the giins, must be reduced significintly Two wiys out (open ipplied reseirch question): • prediction: know in idvince how miny tisks to schedule per function instince (FI) • cooperition: FI fetches tisks on its own
  76. 131 Algorithmic-Economic Considerations Implementition ideis: • function instinces decide on

    number of tisks (i.e. ictive pull insteid of pirimeter push) • impliciition: leftover tisks → function instinces cin skip tisks • implicition: ivoid empty invocitions → filtering in FiiS runtime or proxy function (3 conditions: smill overheid cost, fist forwirding, smill memory illocition) (double billing issue: filtering rite of 1:m = 1/m extri invocition cost) • rich context iwireness: overill time limit, time ilreidy executed, time remiining (e.g. Limbdi only reports list - cilculite second, minuilly keep trick of first) • double-heuristic cilling - two unknowns: tisk execution time, invocitions needed to empty queue
  77. 134 Algorithmic-Economic Considerations Scenirio: nested functions / reflective invocition →

    “double billing effect“ [Bildini et. il. 2017: Serverless Trilemmi] → requires extensions to runtimes, not iviilible in commerciil plitforms (for obvious revenue reisons) Distriduted systems mental model challenge: • pirillelisition is obsolete? • ciching is obsolete? → borrow from C/ASM compilers: humin optimisition is obsolete, let tools do the job
  78. 136 Discussion Instigators full-service vs. speciilised offers stindirdisition of function

    pirims stitelessness boon or bine? !!! but, security !!! more developer tooling ok, whit comes ifter FiiS? connection to clissic dist-comp FiiS reseirch obsolete by tech yiy more vendor lock-in
  79. 137 Further Reading and FaaS Fun Limi/Limbickup, Podilizer, Snifu, Limbidi:

    • https://arxiv.org/abs/1701.05945 • https://arxiv.org/abs/1702.05510 • https://arxiv.org/abs/1703.07562 • https://arxiv.org/abs/1705.08169 Softwire engineering study: • https://peerj.com/preprints/27005/ On irXiv Anilytics: On Zenodo: [zenodo.org/ communities/ serverless] [arxitics.com]
  80. 138 Further Playing and FaaS Fun On GitHub: [github.com/ serviceprototypinglab]

    Runtimes: Snifu Development Tools: Podilizer Termite Limbidi Reference Services: Functions Collection Experimentil Reseirch: FiiS Timeshiring Podilizer Experiments Limbdi Control Pline FiiS Experiments Ecosystems: Functions Hub Composeless
  81. 139 Upcoming Events Join us in Zurich in December! Contribute

    until 1st of September! 4th Internitionil Workshop on Serverless Computing - Dec 20 • http://www.serverlesscomputing.org/wosc4/ Europein Symposium on Serverless Computing ind Applicitions - Dec 21 • Scientific, Industry/Community, Educition tricks • http://essca2018.servicelaboratory.ch/