Slide 1

Slide 1 text

Zürcher Fachhochschule Distributed Service Prototyping with Cloud Functions ⓕ - ⓕ - ⓕ - ⓕ - ⓕ - ⓕ - ⓕ Josef Spillner Service Prototyping Lib (blog.zhiw.ch/icclib) Zurich University of Applied Sciences Jul 2, 2018 | ICDCS‘18 | Vienni, Austrii

Slide 2

Slide 2 text

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.“

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

4 Your Tutorial Instructor Josef Spillner ● 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/

Slide 5

Slide 5 text

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)

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

7 You gho are you? Signup function (optionil): (http://1b.yt/erURF) https://openwhisk.ng.bluemix.net/api/v1/web/ZHAW%20ISPROT_ISPROT17/default/icdcstutorial.html

Slide 8

Slide 8 text

8 Part I - Cloud Function Development I-1: Basics

Slide 9

Slide 9 text

9 Cloud Applications [emphitictechnologies.com] Ideilly: ● progrimmible / iutomitible service ● conveniently miniged vs. iwireness ● elistic scilibility ● resilience ● provisioned & billed on demind → conveying cloud computing chiricteristics

Slide 10

Slide 10 text

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.)

Slide 11

Slide 11 text

11 Industry Perspective: JFK Dec‘17

Slide 12

Slide 12 text

12 Industry Perspective‘17: Cloud Apps [https://github.com/cncf/lindscipe, Oct‘17]

Slide 13

Slide 13 text

13 Industry Perspective‘17: FaaS [Astisii Myers, Memory Leik, Oct‘17]

Slide 14

Slide 14 text

14 CNCF most recent: May‘18 [https://github.com/cncf/lindscipe, Jun‘18]

Slide 15

Slide 15 text

15 Awesome Serverless List [https://github.com/iniibol/iwesome-serverless, Jun‘18]

Slide 16

Slide 16 text

16 Academic Perspective: Clouds & FaaS

Slide 17

Slide 17 text

17 Academic Perspective: Serverless Brief survey of serverless plitforms: ● AWS Limbdi ● Google Cloud Functions ● Microsoft Azure Functions ● IBM OpenWhisk ● Open Limbdi, Gilictic Fog, Auth0, ...

Slide 18

Slide 18 text

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“

Slide 19

Slide 19 text

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 ...

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

22 FaaS Technology Positioning code-level microservices sincere pay-per-use

Slide 23

Slide 23 text

23 FaaS Technology Positioning

Slide 24

Slide 24 text

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)

Slide 25

Slide 25 text

25 FaaS Chronology

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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:

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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{ 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:

Slide 30

Slide 30 text

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:

Slide 31

Slide 31 text

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": "", .... }, .... 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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

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:

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

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))

Slide 36

Slide 36 text

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'])

Slide 37

Slide 37 text

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.

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

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]

Slide 42

Slide 42 text

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)

Slide 43

Slide 43 text

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?

Slide 44

Slide 44 text

44 COFFEE

Slide 45

Slide 45 text

45 Part I - Cloud Function Development I-2: Hands-On

Slide 46

Slide 46 text

46 Hands-On FaaS Development → Compinion script: no. 8 / IBM Cloud Functions Nr. 8

Slide 47

Slide 47 text

47 Part I - Cloud Function Development I-3: Research

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

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

Slide 52

Slide 52 text

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...

Slide 53

Slide 53 text

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?

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

55 Automated Decomposition (DT: decision tree, dot: code trinsformition) NP/P-solvible? chiricteristics knowledge bise (ipplicition, runtime)

Slide 56

Slide 56 text

56 Mixed-Technology Hubs/Marketplaces currently, ilmost ilwiys single-technology → quility ind productivity implicitions?

Slide 57

Slide 57 text

57 Function Marketplace Designs “Functions Hub“

Slide 58

Slide 58 text

58 Function Marketplace Designs “Functions Hub“ evolution [joint work with Y. Bogido]

Slide 59

Slide 59 text

59 Function Marketplace Designs SPLib‘s Function Hub Prototype bised on Snifu beiten by 49 days in 2018 http://functionhub-zhiw-test1.ippuioipp.ch/

Slide 60

Slide 60 text

60 Programming Perspective

Slide 61

Slide 61 text

61 Transformation Overview

Slide 62

Slide 62 text

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)

Slide 63

Slide 63 text

63 Transformation Algorithm (Java Exc.)

Slide 64

Slide 64 text

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

Slide 65

Slide 65 text

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

Slide 66

Slide 66 text

66 Lambada Nr. 1

Slide 67

Slide 67 text

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)

Slide 68

Slide 68 text

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“))

Slide 69

Slide 69 text

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

Slide 70

Slide 70 text

70 Lambada Eximples (not shown: monids, decoritors)

Slide 71

Slide 71 text

71 Podilizer

Slide 72

Slide 72 text

72 Podilizer Eximples locil proxy method hosted function

Slide 73

Slide 73 text

73 Podilizer Eximples (proxy method)

Slide 74

Slide 74 text

74 Podilizer Eximples (hosted function)

Slide 75

Slide 75 text

75 Termite Annotitions: @Limbdi(region=..., memory=...,timeout=...) Nr. 2

Slide 76

Slide 76 text

76 Termite Limbdificition sequence (Miven + AspectJ integrition)

Slide 77

Slide 77 text

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'])

Slide 78

Slide 78 text

78 Challenges in FaaSification clustering deep FiiSificition (code inspection) both open reseirch problems

Slide 79

Slide 79 text

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

Slide 80

Slide 80 text

80 Challenge: Debugging

Slide 81

Slide 81 text

81 Challenge: Debugging

Slide 82

Slide 82 text

82 Challenge: Debugging

Slide 83

Slide 83 text

83 FaaS Software Engineering in Practice https://peerj.com/preprints/27005/

Slide 84

Slide 84 text

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

Slide 85

Slide 85 text

85 LUNCH

Slide 86

Slide 86 text

86 Part II - Cloud Function Execution I-1: Basics

Slide 87

Slide 87 text

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

Slide 88

Slide 88 text

88 Runtime Overview: Providers&Stacks

Slide 89

Slide 89 text

89 Runtime Overview: Python Examples

Slide 90

Slide 90 text

90 Runtime Overview: Provider Pricing (constintly outdited tible)

Slide 91

Slide 91 text

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)

Slide 92

Slide 92 text

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

Slide 93

Slide 93 text

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)

Slide 94

Slide 94 text

94 Runtimes and Tools control pline deployment minigement billing user interfices

Slide 95

Slide 95 text

95 Runtimes and Tools: Architecture Exempliry FiiS system irchitecture (OpenWhisk-inspired):

Slide 96

Slide 96 text

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)

Slide 97

Slide 97 text

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)

Slide 98

Slide 98 text

98 Runtime Examples: OpenLambda Nr. 5 (reseirch perspective, U of Wisconsin)

Slide 99

Slide 99 text

99 Runtime Examples: Fission Nr. 4

Slide 100

Slide 100 text

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 }

Slide 101

Slide 101 text

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

Slide 102

Slide 102 text

102 Architecture Subsystems ● pirsing functions ● triggering functions (connectors) ● iuthenticition ● forwirding ● executing functions ● logging output ind trices Linguige support ● Python ● Jivi, C, JiviScript ● generic (contiiners)

Slide 103

Slide 103 text

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), ...

Slide 104

Slide 104 text

104 Snafu Scenarios Integrition into the wider FiiS ecosystem snafu-import Snifu Funktion Fission Kubeless ... targets sources AWS IBM Google $ snifu-import \ --source \ --tirget $ iliis iws=“iws \ --endpoint-url \ http://locilhost:10000“ $ wsk property set \ --ipihost \ locilhost:10000 $ ./tools/pitch-gcloud OVH

Slide 105

Slide 105 text

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

Slide 106

Slide 106 text

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 -s -e # Sife mode $ snifu-control -P

Slide 107

Slide 107 text

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 ...

Slide 108

Slide 108 text

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

Slide 109

Slide 109 text

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

Slide 110

Slide 110 text

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)

Slide 111

Slide 111 text

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

Slide 112

Slide 112 text

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?

Slide 113

Slide 113 text

113 Part II - Cloud Function Execution I-2: Hands-On

Slide 114

Slide 114 text

114 Hands-On FaaS Execution → Compinion script: no. 3 / Snifu Nr. 3

Slide 115

Slide 115 text

115 COFFEE

Slide 116

Slide 116 text

116 Part II - Cloud Function Execution I-3: Research

Slide 117

Slide 117 text

117 Research Overview CostHit

Slide 118

Slide 118 text

118 Systematic Research Overview Interested in joining effort?

Slide 119

Slide 119 text

119 Challenge: Performance

Slide 120

Slide 120 text

120 Challenge: Performance

Slide 121

Slide 121 text

121 Challenge: Performance

Slide 122

Slide 122 text

122 Challenge: Performance / Snafu Traces preliminary results (designed to contribute to debugging chillenge is well) [reseirch contribution by KTH students]

Slide 123

Slide 123 text

123 Challenge: Ecosystem

Slide 124

Slide 124 text

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?

Slide 125

Slide 125 text

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

Slide 126

Slide 126 text

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)

Slide 127

Slide 127 text

127 Algorithmic-Technical Considerations Implementition: oppcaching.py

Slide 128

Slide 128 text

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

Slide 129

Slide 129 text

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

Slide 130

Slide 130 text

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

Slide 131

Slide 131 text

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

Slide 132

Slide 132 text

132 Algorithmic-Economic Considerations Implementition: faasproxy.py ind faasconsumer.py

Slide 133

Slide 133 text

133 Algorithmic-Economic Considerations Implementition: faasproxy.py ind faasconsumer.py

Slide 134

Slide 134 text

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

Slide 135

Slide 135 text

135 Discussion/Problem Solving

Slide 136

Slide 136 text

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

Slide 137

Slide 137 text

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]

Slide 138

Slide 138 text

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

Slide 139

Slide 139 text

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/