SlideShare uma empresa Scribd logo
1 de 94
Università   Faculty
                                                              della        of Informatics
                                                              Svizzera
                                                              Italiana
               S
               A Scripting Language for
               High-Performance
               RESTful Web Services

                                                            Daniele Bonetta
                           Achille Peternier, Cesare Pautasso, Walter Binder
                                                       Faculty of Informatics
                                                  University of Lugano - USI
                                                                 Switzerland
                http://sosoa.inf.usi.ch/s
                                            1
Monday, February 27, 12
Università   Faculty
                                                                       della        of Informatics

                              RESTful Web Services
                                                                       Svizzera
                                                                       Italiana




                          Services using the HTTP protocol

                                              HTTP            HTTP           HTTP
                                              Client          Client         Client
       REST Architectural Style
          Client-Server Architecture
          Stateless Interaction
          Resources (Stateful, URIs)                   RESTful service
          Uniform Interface
          (GET,PUT,DELETE,POST, ...)                   resource   resource
                                                       resource   resource




                                          2
Monday, February 27, 12
Università   Faculty
                                                        della        of Informatics

                                    Goal
                                                        Svizzera
                                                        Italiana




                          Develop and compose RESTful
                                services that scale




                                       3
Monday, February 27, 12
Università   Faculty
                                                         della        of Informatics

                                     Goal
                                                         Svizzera
                                                         Italiana




                           Develop and compose RESTful
                                 services that scale

                          #clients




                                        3
Monday, February 27, 12
Università   Faculty
                                                         della        of Informatics

                                     Goal
                                                         Svizzera
                                                         Italiana




                           Develop and compose RESTful
                                 services that scale

                          #clients             #cores




                                        3
Monday, February 27, 12
Università   Faculty
                                                              della        of Informatics

                                        Goal
                                                              Svizzera
                                                              Italiana




                           Develop and compose RESTful
                                 services that scale

                          #clients                 #cores
                            using safe implicit parallelism




                                           3
Monday, February 27, 12
Università   Faculty
                                                               della        of Informatics

                                        Node.JS
                                                               Svizzera
                                                               Italiana




                          Asynchronous Event-loop based solution




                                            4
Monday, February 27, 12
Università   Faculty
                                                                     della        of Informatics

                                           Node.JS
                                                                     Svizzera
                                                                     Italiana




                          Asynchronous Event-loop based solution

                                on(‘request’, function(req,res) {
                                    // ...
                                })

                                on(‘response’, function(req,res) {
                                    // ...
                                })




                                                 4
Monday, February 27, 12
Università   Faculty
                                                                     della        of Informatics

                                           Node.JS
                                                                     Svizzera
                                                                     Italiana




                          Asynchronous Event-loop based solution

                                on(‘request’, function(req,res) {
                                    // ...
                                })

                                on(‘response’, function(req,res) {
                                    // ...
                                })


                             Asynchronous nonblocking I/O ✔




                                                 4
Monday, February 27, 12
Università   Faculty
                                                                     della        of Informatics

                                           Node.JS
                                                                     Svizzera
                                                                     Italiana




                          Asynchronous Event-loop based solution

                                on(‘request’, function(req,res) {
                                    // ...
                                })

                                on(‘response’, function(req,res) {
                                    // ...
                                })


                             Asynchronous nonblocking I/O ✔
                               No locks/synchronization ✔




                                                 4
Monday, February 27, 12
Università   Faculty
                                                                      della        of Informatics

                                            Node.JS
                                                                      Svizzera
                                                                      Italiana




                          Asynchronous Event-loop based solution

                                 on(‘request’, function(req,res) {
                                     // ...
                                 })

                                 on(‘response’, function(req,res) {
                                     // ...
                                 })


                             Asynchronous nonblocking I/O ✔
                               No locks/synchronization ✔
                          Sequential composition: nested callbacks ✘


                                                  4
Monday, February 27, 12
Università   Faculty
                                                                      della        of Informatics

                                            Node.JS
                                                                      Svizzera
                                                                      Italiana




                          Asynchronous Event-loop based solution

                                 on(‘request’, function(req,res) {
                                     // ...
                                 })

                                 on(‘response’, function(req,res) {
                                     // ...
                                 })


                             Asynchronous nonblocking I/O ✔
                                No locks/synchronization ✔
                          Sequential composition: nested callbacks ✘
                          Callbacks need to be short: never block ✘

                                                  4
Monday, February 27, 12
Università   Faculty
                                                                      della        of Informatics

                                            Node.JS
                                                                      Svizzera
                                                                      Italiana




                          Asynchronous Event-loop based solution

                                 on(‘request’, function(req,res) {
                                     // ...
                                 })

                                 on(‘response’, function(req,res) {
                                     // ...
                                 })


                             Asynchronous nonblocking I/O ✔
                                No locks/synchronization ✔
                          Sequential composition: nested callbacks ✘
                          Callbacks need to be short: never block ✘
                                 Master worker parallelism ✘
                                                  4
Monday, February 27, 12
Università   Faculty
                                                             della        of Informatics
                                                             Svizzera
                                                             Italiana




                          The S Scripting Language
                            A DSL for RESTful Web Services
                            Development and Composition




                                           5
Monday, February 27, 12
Università   Faculty
                                                             della        of Informatics
                                                             Svizzera
                                                             Italiana




                                               S erv ices
                                S tate ful
                          The S Scripting Language
                            A DSL for RESTful Web Services
                            Development and Composition




                                           5
Monday, February 27, 12
Università   Faculty
                                                              della        of Informatics
                                                              Svizzera
                                                              Italiana




                                       ab le
                                 ca l
                               S              erv ices
                                      teful S
                                Sta
                          The S Scripting Language
                             A DSL for RESTful Web Services
                             Development and Composition




                                            5
Monday, February 27, 12
Università   Faculty
                                                                  della        of Informatics

                                 S: Design Principles
                                                                  Svizzera
                                                                  Italiana




                          High-level architectural abstractions




                           Simple, clean programming model




                                            6
Monday, February 27, 12
Università   Faculty
                                                                           della        of Informatics

                                     S: Design Principles
                                                                           Svizzera
                                                                           Italiana




                             High-level architectural abstractions
                                  Services compose resources
                          No threads/processes, no synchronization/locks
                                        Stateful services


                               Simple, clean programming model




                                                 6
Monday, February 27, 12
Università   Faculty
                                                                           della        of Informatics

                                     S: Design Principles
                                                                           Svizzera
                                                                           Italiana




                             High-level architectural abstractions
                                  Services compose resources
                          No threads/processes, no synchronization/locks
                                        Stateful services


                               Simple, clean programming model
                                   Allow blocking function calls
                               Synchronous I/O + parallel constructs
                                    Uniform interface and URIs



                                                 6
Monday, February 27, 12
Università   Faculty
                                                   della        of Informatics

                                 S: Architecture
                                                   Svizzera
                                                   Italiana




                          S service




                                        7
Monday, February 27, 12
Università   Faculty
                                                             della        of Informatics

                                          S: Architecture
                                                             Svizzera
                                                             Italiana




                                   S service


                      S resource   S resource   S resource




                                                    7
Monday, February 27, 12
Università   Faculty
                                                                   della        of Informatics

                                           S: Architecture
                                                                   Svizzera
                                                                   Italiana




                                    S service


                      S resource    S resource     S resource


                    Node     Node    Node        Node       Node
                     .JS      .JS     .JS         .JS        .JS




                                                        7
Monday, February 27, 12
Università   Faculty
                                                                    della        of Informatics

                                            S: Architecture
                                                                    Svizzera
                                                                    Italiana




                                     S service


                      S resource     S resource     S resource


                    Node      Node    Node        Node       Node
                     .JS       .JS     .JS         .JS        .JS


                          S IPC Communication framework




                                                         7
Monday, February 27, 12
Università   Faculty
                                                                     della        of Informatics

                                             S: Architecture
                                                                     Svizzera
                                                                     Italiana




                                      S service


                      S resource      S resource     S resource


                    Node      Node     Node        Node       Node
                     .JS       .JS      .JS         .JS        .JS


                          S IPC Communication framework


                                   Nonblocking I/O




                                                          7
Monday, February 27, 12
Università   Faculty
                                                                            della        of Informatics

                                             S: Architecture
                                                                            Svizzera
                                                                            Italiana




                                      S service                      Synchronous
                                                                       blocking
                      S resource      S resource     S resource         S code

                    Node      Node     Node        Node       Node
                     .JS       .JS      .JS         .JS        .JS


                          S IPC Communication framework


                                   Nonblocking I/O




                                                          7
Monday, February 27, 12
Università   Faculty
                                                                             della        of Informatics

                                             S: Architecture
                                                                             Svizzera
                                                                             Italiana




                                      S service                      Synchronous
                                                                       blocking
                      S resource      S resource     S resource         S code

                    Node      Node     Node        Node       Node
                     .JS       .JS      .JS         .JS        .JS   Asynchronous
                                                                      nonblocking
                          S IPC Communication framework
                                                                     Node.JS code
                                   Nonblocking I/O




                                                          7
Monday, February 27, 12
Università   Faculty
                                                                                 della        of Informatics

                                             S: Architecture
                                                                                 Svizzera
                                                                                 Italiana




                                      S service                              No
                                                                      processes/threads
                      S resource      S resource     S resource          locks/sync

                    Node      Node     Node        Node       Node
                     .JS       .JS      .JS         .JS        .JS     Multiple Node.JS
                                                                          processes
                          S IPC Communication framework
                                                                     (IPC + shared state)
                                   Nonblocking I/O




                                                          8
Monday, February 27, 12
Università   Faculty
                                                  della        of Informatics

                                 Hello S
                                                  Svizzera
                                                  Italiana




                          res ‘/hello’ on GET {
                              respond ‘World!’
                          }




                                    9
Monday, February 27, 12
Università   Faculty
                                                  della        of Informatics

                                 Hello S
                                                  Svizzera
                                                  Italiana




    Request
    Handler
                          res ‘/hello’ on GET {
                              respond ‘World!’
                          }




                                    9
Monday, February 27, 12
Università   Faculty
                                                   della        of Informatics

                                  Hello S
                                                   Svizzera
                                                   Italiana




                          URI
    Request
    Handler
                           res ‘/hello’ on GET {
                               respond ‘World!’
                           }




                                     9
Monday, February 27, 12
Università   Faculty
                                                    della        of Informatics

                                  Hello S
                                                    Svizzera
                                                    Italiana




                          URI                HTTP Verb
    Request
    Handler
                           res ‘/hello’ on GET {
                               respond ‘World!’
                           }




                                     9
Monday, February 27, 12
Università   Faculty
                                                     della        of Informatics

                                   Hello S
                                                     Svizzera
                                                     Italiana




                          URI                 HTTP Verb
    Request
    Handler
                           res ‘/hello’ on GET {
                               respond ‘World!’
                           }



             Any valid JavaScript statement
                            +
                 S specific constructs
                                       9
Monday, February 27, 12
Università   Faculty
                                                        della        of Informatics

                                    Hello S
                                                        Svizzera
                                                        Italiana




                          res ‘/hello’ on GET {
                              respond ‘World!’
                          }


                           HTTP                  S
                           Client             Service




                                       10
Monday, February 27, 12
Università   Faculty
                                                           della        of Informatics

                                    Hello S
                                                           Svizzera
                                                           Italiana




                          res ‘/hello’ on GET {
                              respond ‘World!’
                          }


                           HTTP                  S
                           Client             Service

                                     GET /hello HTTP/1.1
                                     User-Agent: curl
                                     Accept: */*
                                     Host: your.host



                                       10
Monday, February 27, 12
Università   Faculty
                                                         della        of Informatics

                                    Hello S
                                                         Svizzera
                                                         Italiana




                          res ‘/hello’ on GET {
                              respond ‘World!’
                          }


                           HTTP                  S
                           Client             Service

                                     HTTP/1.1 200 OK
                                     Content-Type: text/plain

                                     World!



                                       11
Monday, February 27, 12
Università   Faculty
                                                             della        of Informatics

                                    Compositions
                                                             Svizzera
                                                             Italiana




                          res ‘/hello1’ on GET {
                              respond get ‘http://www.a.b’
                          }




                          res ‘/hello2’ on GET {
                              respond get ‘/hello1’
                          }




                                           12
Monday, February 27, 12
Università   Faculty
                                                             della        of Informatics

                                    Compositions
                                                             Svizzera
                                                             Italiana




                          res ‘/hello1’ on GET {
                              respond get ‘http://www.a.b’
                          }




                          res ‘/hello2’ on GET {
                              respond get ‘/hello1’
                          }



                                            Native HTTP support


                                           12
Monday, February 27, 12
Università   Faculty
                                                             della        of Informatics

                                    Compositions
                                                             Svizzera
                                                             Italiana




                          res ‘/hello1’ on GET {
                              respond get ‘http://www.a.b’
                          }




                          res ‘/hello2’ on GET {
                              respond get ‘/hello1’
                          }



            HTTP
            Client



                                           13
Monday, February 27, 12
Università   Faculty
                                                             della        of Informatics

                                     Compositions
                                                             Svizzera
                                                             Italiana




                          res ‘/hello1’ on GET {
                              respond get ‘http://www.a.b’
                          }




                          res ‘/hello2’ on GET {
                              respond get ‘/hello1’
                          }



            HTTP
                                  /hello2
            Client



                                            13
Monday, February 27, 12
Università   Faculty
                                                             della        of Informatics

                                     Compositions
                                                             Svizzera
                                                             Italiana




                          res ‘/hello1’ on GET {
                              respond get ‘http://www.a.b’
                          }




                          res ‘/hello2’ on GET {
                              respond get ‘/hello1’
                          }



            HTTP
                                  /hello2        /hello1
            Client



                                            13
Monday, February 27, 12
Università   Faculty
                                                             della        of Informatics

                                     Compositions
                                                             Svizzera
                                                             Italiana




                          res ‘/hello1’ on GET {
                              respond get ‘http://www.a.b’
                          }




                          res ‘/hello2’ on GET {
                              respond get ‘/hello1’
                          }



            HTTP
                                  /hello2        /hello1     www.a.b
            Client



                                            13
Monday, February 27, 12
Università   Faculty
                                                             della        of Informatics

                                     Compositions
                                                             Svizzera
                                                             Italiana




                          res ‘/hello1’ on GET {
                              respond get ‘http://www.a.b’
                          }




                          res ‘/hello2’ on GET {
                              respond get ‘/hello1’
                          }



            HTTP
                                  /hello2        /hello1     www.a.b
            Client



                                            13
Monday, February 27, 12
Università   Faculty
                                                                    della        of Informatics

                                   Concurrency & Parallelism
                                                                    Svizzera
                                                                    Italiana




                  res ‘/res1‘ on GET {

                          // ...

                          // CPU/bound blocking call
                          var a = foo()
                          respond a
                  }

                  res ‘/res2’ on GET {

                          // ...
                          res r = ‘http://www.google.ch/search=@’

                          // I/O bound operation
                          boo = r.get(‘key’)
                          respond boo
                  }


                                                   14
Monday, February 27, 12
Università   Faculty
                                                                       della        of Informatics

                                   Concurrency & Parallelism
                                                                       Svizzera
                                                                       Italiana




                  res ‘/res1‘ on GET {

                          // ...                          Atomically
                          // CPU/bound blocking call      executed
                          var a = foo()                     blocks
                          respond a
                  }

                  res ‘/res2’ on GET {

                          // ...
                          res r = ‘http://www.google.ch/search=@’

                          // I/O bound operation
                          boo = r.get(‘key’)
                          respond boo
                  }


                                                   14
Monday, February 27, 12
Università   Faculty
                                                                       della        of Informatics

                                   Concurrency & Parallelism
                                                                       Svizzera
                                                                       Italiana




                  res ‘/res1‘ on GET {

                          // ...

                          // CPU/bound blocking call        Parallel
                          var a = foo()                    resources
                          respond a
                  }

                  res ‘/res2’ on GET {

                          // ...
                          res r = ‘http://www.google.ch/search=@’

                          // I/O bound operation
                          boo = r.get(‘key’)
                          respond boo
                  }


                                                   15
Monday, February 27, 12
Università   Faculty
                                                                    della        of Informatics

                                   Concurrency & Parallelism
                                                                    Svizzera
                                                                    Italiana




                  res ‘/res1‘ on GET {

                          // ...

                          // CPU/bound blocking call      Synchronous
                          var a = foo()                    operations
                          respond a
                  }

                  res ‘/res2’ on GET {

                          // ...
                          res r = ‘http://www.google.ch/search=@’

                          // I/O bound operation
                          boo = r.get(‘key’)
                          respond boo
                  }


                                                   16
Monday, February 27, 12
Università   Faculty
                                                       della        of Informatics

                           (1) CPU-bound Operations    Svizzera
                                                       Italiana




                           Request Handler Processor


                          /res          Worker #1

                          Router
                                          Worker #n




                                             17
Monday, February 27, 12
Università   Faculty
                                                       della        of Informatics

                           (1) CPU-bound Operations    Svizzera
                                                       Italiana




                           Request Handler Processor


                          /res          Worker #1

                          Router
                                          Worker #n




                                             17
Monday, February 27, 12
Università   Faculty
                                                               della        of Informatics

                           (1) CPU-bound Operations            Svizzera
                                                               Italiana




                           Request Handler Processor


                          /res          Worker #1         To clients
                                                       (HTTP response)
                          Router
                                          Worker #n


         From clients
       (HTTP requests)




                                             17
Monday, February 27, 12
Università   Faculty
                                                               della        of Informatics

                           (1) CPU-bound Operations            Svizzera
                                                               Italiana



                            (2) I/O-bound Operations


                           Request Handler Processor


                          /res          Worker #1         To clients
                                                       (HTTP response)
                          Router
                                          Worker #n


         From clients       Parallelism degree
       (HTTP requests)        controller (PI)



                                             17
Monday, February 27, 12
Università   Faculty
                                                                   della        of Informatics

                           (1) CPU-bound Operations                Svizzera
                                                                   Italiana



                            (2) I/O-bound Operations

                                                       To external resources
                           Request Handler Processor      (through HTTP)
        From other
          workers
                          /res          Worker #1            To clients
                                                          (HTTP response)
                          Router
                                          Worker #n
                                                          To internal resources
                                                              (through IPC)
         From clients       Parallelism degree
       (HTTP requests)        controller (PI)



                                             17
Monday, February 27, 12
Università   Faculty
                                                            della        of Informatics

                          (2) I/O-bound Operations
                                                            Svizzera
                                                            Italiana




                Event-based compilation output targeting Node.JS




                                        18
Monday, February 27, 12
Università   Faculty
                                                            della        of Informatics

                          (2) I/O-bound Operations
                                                            Svizzera
                                                            Italiana




                Event-based compilation output targeting Node.JS



               • Synchronous I/O operations are desynchronized
               by the compiler using multiple callbacks




                                        18
Monday, February 27, 12
Università   Faculty
                                                            della        of Informatics

                          (2) I/O-bound Operations
                                                            Svizzera
                                                            Italiana




                Event-based compilation output targeting Node.JS



               • Synchronous I/O operations are desynchronized
               by the compiler using multiple callbacks

               • Callbacks are scheduled by the runtime using an
               event-based approach.




                                        18
Monday, February 27, 12
Università   Faculty
                                                      della        of Informatics

                          Sync to Async Compilation
                                                      Svizzera
                                                      Italiana




                                S vs. Node.JS

       res ‘/example’ on GET {
           var a = get ‘www.google.com’
           var b = get ‘www.bing.com’
           var c = get ‘www.yahoo.com’
           respond a+b+c
       }




                                      19
Monday, February 27, 12
Università   Faculty
                                                                            della        of Informatics

                           Sync to Async Compilation
                                                                            Svizzera
                                                                            Italiana




                                         S vs. Node.JS
      res ‘/example’ on GET {            http.createServer(function(creq,cres){
          var a = get ‘www.google.com’      if(creq.method==‘GET’&&creq.url==‘/example’) {
          var b = get ‘www.bing.com’
                                                var a,b,c = ‘’
          var c = get ‘www.yahoo.com’
          respond a+b+c                         startGet(‘www.google.com’,
      }                                            function(req,res) {
                                                      a = res.body
                                                      startGet(‘www.bing.com’,
                                                         function(req,res) {
                                                            b = res.body
                                                                startGet(‘www.yahoo.com’,
                                                                   function(req,res) {
                                                                      c = res.body
                                                                      cres.end(a+b+c)
                                                                   })
                                                             })
                                                     })
                                             }
                                         })




                                                19
Monday, February 27, 12
Università   Faculty
                                                      della        of Informatics

                          Sync to Async Compilation
                                                      Svizzera
                                                      Italiana




                                S vs. Node.JS
       res ‘/example’ on GET {
          par {
            var a = get ‘www.google.com’
            var b = get ‘www.bing.com’
            var c = put ‘www.a.b/?d=’+b
            respond a+c
       }}




                                      20
Monday, February 27, 12
Università   Faculty
                                                                                     della        of Informatics

                                          Sync to Async Compilation
                                                                                     Svizzera
                                                                                     Italiana




                                                 S vs. Node.JS
      res ‘/example’ on GET {                    http.createServer(function(req,res) {
         par {                                      if(creq.method==‘GET’&&creq.url==‘/example’) {
           var a = get ‘www.google.com’
                                                      var G = {}
           var b = get ‘www.bing.com’
           var c = put ‘www.a.b/?d=’+b                on(‘done1’, function(result){
           respond a+c                                    G.a = result; emit(‘done3’)})
      }}                                              on(‘done2’, function(result){
                                                          G.b = result;
                     get            get                   startPut(‘www.a.b/d?=‘+G.b, ‘done4’)
                                                      })
                                                      on(‘done4’, function(result) {
                              var b = ...                 G.c = result;
                                                          emit(‘done5’)
                     var a = ...                      })
                                       put            onAll([‘done3’,‘done5’], function() {
                                                          res.end(G.a+G.c)
                                   var c = ...        })
                                                      startGet(‘www.google.com’, ‘done1’)
                                                      startGet(‘www.bing.com’, ‘done2’)
                             respond                }
                                                 })


                                                        20
Monday, February 27, 12
Università   Faculty
                                                                                   della        of Informatics

                                      Sync to Async Compilation
                                                                                   Svizzera
                                                                                   Italiana




                                         http.createServer(function(req,res) {
                                            if(creq.method==‘GET’&&creq.url==‘/example’) {
                                              var G = {}
                                              on(‘done1’, function(result){
          get               get                   G.a = result; emit(‘done3’)})
                                              on(‘done2’, function(result){
                          var b                   G.b = result;
                                                  startPut(‘www.a.b/d?=‘+G.b, ‘done4’)
             var a                            })
                              put
                                              on(‘done4’, function(result) {
                                                  G.c = result;
                              var c               emit(‘done5’)
                                              })
                   respond                    onAll([‘done3’,‘done5’], function() {
                                                  res.end(G.a+G.c)
                                              })
                                              startGet(‘www.google.com’, ‘done1’)
                                              startGet(‘www.bing.com’, ‘done2’)
                                            }
                                         })



                                                       21
Monday, February 27, 12
Università   Faculty
                                                                                   della        of Informatics

                                      Sync to Async Compilation
                                                                                   Svizzera
                                                                                   Italiana




                 Callbacks
                registration             http.createServer(function(req,res) {
                                            if(creq.method==‘GET’&&creq.url==‘/example’) {
                                              var G = {}
                                              on(‘done1’, function(result){
          get               get                   G.a = result; emit(‘done3’)})
                                              on(‘done2’, function(result){
                          var b                   G.b = result;
                                                  startPut(‘www.a.b/d?=‘+G.b, ‘done4’)
             var a                            })
                              put
                                              on(‘done4’, function(result) {
                                                  G.c = result;
                              var c               emit(‘done5’)
                                              })
                   respond                    onAll([‘done3’,‘done5’], function() {
                                                  res.end(G.a+G.c)
                                              })
                                              startGet(‘www.google.com’, ‘done1’)
                                              startGet(‘www.bing.com’, ‘done2’)
                                            }
                                         })



                                                       21
Monday, February 27, 12
Università   Faculty
                                                                                   della        of Informatics

                                      Sync to Async Compilation
                                                                                   Svizzera
                                                                                   Italiana




                 Callbacks
                registration             http.createServer(function(req,res) {
                                            if(creq.method==‘GET’&&creq.url==‘/example’) {
                                              var G = {}
                                              on(‘done1’, function(result){
          get               get                   G.a = result; emit(‘done3’)})
                                              on(‘done2’, function(result){
                          var b                   G.b = result;
                                                  startPut(‘www.a.b/d?=‘+G.b, ‘done4’)
             var a                            })
                              put
                                              on(‘done4’, function(result) {
                                                  G.c = result;
                              var c               emit(‘done5’)
                                              })
                   respond                    onAll([‘done3’,‘done5’], function() {
                                                  res.end(G.a+G.c)
                                              })
                                              startGet(‘www.google.com’, ‘done1’)
                                              startGet(‘www.bing.com’, ‘done2’)
                                            }
                                         })



                                                       21
Monday, February 27, 12
Università   Faculty
                                                                                   della        of Informatics

                                      Sync to Async Compilation
                                                                                   Svizzera
                                                                                   Italiana




                                         http.createServer(function(req,res) {
                                            if(creq.method==‘GET’&&creq.url==‘/example’) {
                                              var G = {}
                                              on(‘done1’, function(result){
          get               get                   G.a = result; emit(‘done3’)})
                                              on(‘done2’, function(result){
                          var b                   G.b = result;
                                                  startPut(‘www.a.b/d?=‘+G.b, ‘done4’)
             var a                            })
                              put
                                              on(‘done4’, function(result) {
                                                  G.c = result;
                              var c               emit(‘done5’)
                                              })
                   respond                    onAll([‘done3’,‘done5’], function() {
                                                  res.end(G.a+G.c)
                                              })
                                              startGet(‘www.google.com’, ‘done1’)
                                              startGet(‘www.bing.com’, ‘done2’)
                                            }
                                         })



                                                       22
Monday, February 27, 12
Università   Faculty
                                                                                   della        of Informatics

                                      Sync to Async Compilation
                                                                                   Svizzera
                                                                                   Italiana




                                         http.createServer(function(req,res) {
                                            if(creq.method==‘GET’&&creq.url==‘/example’) {
                                              var G = {}
                                              on(‘done1’, function(result){
          get               get                   G.a = result; emit(‘done3’)})
                                              on(‘done2’, function(result){
                          var b                   G.b = result;
                                                  startPut(‘www.a.b/d?=‘+G.b, ‘done4’)
             var a                            })
                              put
                                              on(‘done4’, function(result) {
                                                  G.c = result;
                              var c               emit(‘done5’)
                                              })
                   respond                    onAll([‘done3’,‘done5’], function() {
                                                  res.end(G.a+G.c)
                                              })
                                              startGet(‘www.google.com’, ‘done1’)
                                              startGet(‘www.bing.com’, ‘done2’)
                                            }
                                         })



                                                       23
Monday, February 27, 12
Università   Faculty
                                                                                   della        of Informatics

                                      Sync to Async Compilation
                                                                                   Svizzera
                                                                                   Italiana




                                         http.createServer(function(req,res) {
                                            if(creq.method==‘GET’&&creq.url==‘/example’) {
                                              var G = {}
                                              on(‘done1’, function(result){
          get               get                   G.a = result; emit(‘done3’)})
                                              on(‘done2’, function(result){
                          var b                   G.b = result;
                                                  startPut(‘www.a.b/d?=‘+G.b, ‘done4’)
             var a                            })
                              put
                                              on(‘done4’, function(result) {
                                                  G.c = result;
                              var c               emit(‘done5’)
                                              })
                   respond                    onAll([‘done3’,‘done5’], function() {
                                                  res.end(G.a+G.c)
                                              })
                                              startGet(‘www.google.com’, ‘done1’)
                                              startGet(‘www.bing.com’, ‘done2’)
                                            }
                                         })



                                                       23
Monday, February 27, 12
Università   Faculty
                                                                        della        of Informatics

                                  Other Constructs
                                                                        Svizzera
                                                                        Italiana




                          pfor                        res creation
          res ‘/pfor’ on GET {                 res ‘/example’ {
              var L = [1,2,3]                      state s = 0
              var a = ‘’                           on POST {
              res r = ‘www.a.b/val=@’                s++
              pfor (var i in L) {                    res ‘/newResource’+s {
                   a += r.get(L[i])                    on GET { respond s }
              }                                        on DELETE {}
              respond a                              }
            }                                      }
          }                                    }




                                          24
Monday, February 27, 12
Università   Faculty
                                               della        of Informatics

                           Stateful Services
                                               Svizzera
                                               Italiana




            res ‘/helloState’ {
              state s = ‘world’
              on GET {
                respond ‘hello’ + s
              }
              on PUT {
                s = req.name
              }
            }




                                      25
Monday, February 27, 12
Università   Faculty
                                                          della        of Informatics

                           Stateful Services
                                                          Svizzera
                                                          Italiana




            res ‘/helloState’ {
              state s = ‘world’            Shared state
              on GET {
                respond ‘hello’ + s
              }
              on PUT {
                s = req.name
              }
            }




                                      25
Monday, February 27, 12
Università   Faculty
                                                          della        of Informatics

                           Stateful Services
                                                          Svizzera
                                                          Italiana




            res ‘/helloState’ {
              state s = ‘world’            Shared state
              on GET {
                respond ‘hello’ + s        Read-only operations
              }
              on PUT {
                s = req.name
              }
            }




                                      25
Monday, February 27, 12
Università   Faculty
                                                            della        of Informatics

                           Stateful Services
                                                            Svizzera
                                                            Italiana




            res ‘/helloState’ {
              state s = ‘world’              Shared state
              on GET {
                respond ‘hello’ + s           Read-only operations
              }
              on PUT {
                s = req.name
              }                            Write operation
            }




                                      25
Monday, February 27, 12
Università   Faculty
                                                                      della        of Informatics

                             Uniform Interface and Parallelism
                                                                      Svizzera
                                                                      Italiana




                                 HTTP’s Uniform Interface


                          HTTP Verb      Properties        Parallelism

                          HTTP GET     Idempotent, safe,       Yes
                                           stateless
                          HTTP PUT    Idempotent, Side-    If stateless
                                            effects
                      HTTP DELETE     Idempotent, Side-    If stateless
                                            effects
                          HTTP POST      Side-effects      If stateless


                                               26
Monday, February 27, 12
Università   Faculty
                                                                                 della        of Informatics

                                Versioned State Management
                                                                                 Svizzera
                                                                                 Italiana




                          res ‘/res’
                              state s                        Guarantees:
                              on GET {

                              }
                                  // read s
                                                           • Eventual (C)onsistency
                              on PUT {                     • (A)vailability
                              }
                                  // alter s               • (P)artition Tolerance
                          }




                                                               S   V. n
                                                 Worker #1

                                        SLR
                                                       Worker #n
                                    S
                                          V. n                     S
                                                                          V. n


                                                  27
Monday, February 27, 12
Università   Faculty
                                                                                 della        of Informatics

                                Versioned State Management
                                                                                 Svizzera
                                                                                 Italiana




                          res ‘/res’
                              state s                        Guarantees:
                              on GET {

                              }
                                  // read s
                                                           • Eventual (C)onsistency
                              on PUT {                     • (A)vailability
                              }
                                  // alter s               • (P)artition Tolerance
                          }




                                                               S   V. n
                                                 Worker #1
           GET /res
                                        SLR
                                                       Worker #n
                                    S
                                          V. n                     S
                                                                          V. n


                                                  27
Monday, February 27, 12
Università   Faculty
                                                                              della        of Informatics

                                 Versioned State Management
                                                                              Svizzera
                                                                              Italiana




                          res ‘/res’
                              state s                      Guarantees:
                              on GET {

                              }
                                  // read s
                                                         • Eventual (C)onsistency
                              on PUT {                   • (A)vailability
                              }
                                  // alter s             • (P)artition Tolerance
                          }



                                                                 V. n-1
                                                             S
                                               Worker #1

                                        SLR
                                                     Worker #n
                                    S
                                                                 S
                                        V. n                         V. n-1


                                                28
Monday, February 27, 12
Università   Faculty
                                                                              della        of Informatics

                                 Versioned State Management
                                                                              Svizzera
                                                                              Italiana




                          res ‘/res’
                              state s                      Guarantees:
                              on GET {

                              }
                                  // read s
                                                         • Eventual (C)onsistency
                              on PUT {                   • (A)vailability
                              }
                                  // alter s             • (P)artition Tolerance
                          }



                                                                 V. n-1
                                                             S
                                               Worker #1
           PUT /res
                                        SLR
                                                     Worker #n
                                    S
                                                                 S
                                        V. n                         V. n-1


                                                28
Monday, February 27, 12
Università   Faculty
                                                                                della        of Informatics

                                Versioned State Management
                                                                                Svizzera
                                                                                Italiana




                          res ‘/res’
                              state s                        Guarantees:
                              on GET {

                              }
                                  // read s
                                                           • Eventual (C)onsistency
                              on PUT {                     • (A)vailability
                              }
                                  // alter s               • (P)artition Tolerance
                          }




                                                               S   V. n-1
                                                 Worker #1             V. n
            GET /res
                                        SLR
                                                       Worker #n
                                    S
                                          V. n                     S
                                                                       V. n-1


                                                  29
Monday, February 27, 12
Università   Faculty
                                                                          della        of Informatics

                                       Example: // Crawler
                                                                          Svizzera
                                                                          Italiana



                   service crawl {
                       res ‘/crawl‘ on PUT {
                           var filter = require(‘HTMLparser.js’).filter
                           res store = ‘/store?value=@’
                           res crawl = ‘/crawl?list=@’

                              pfor(var i in req.list) {
                                  var list = filter(get req.list[i])
                                  par {
                                      store.put(list)
                                      crawl.put(list)
                                  }
                              }
                          }

                          res ‘/store‘ {
                              state s = ‘’
                              on PUT {
                                  s += req.value
                              }
                              on GET {
                                  respond s
                              }
                          }
                   }


                                                      30
Monday, February 27, 12
Università   Faculty
                                                                          della        of Informatics

                                       Example: // Crawler
                                                                          Svizzera
                                                                          Italiana



                   service crawl {
                       res ‘/crawl‘ on PUT {
                           var filter = require(‘HTMLparser.js’).filter
                           res store = ‘/store?value=@’
                                                                            JavaScript
                           res crawl = ‘/crawl?list=@’                        import
                              pfor(var i in req.list) {
                                  var list = filter(get req.list[i])
                                  par {
                                      store.put(list)
                                      crawl.put(list)
                                  }
                              }
                          }

                          res ‘/store‘ {
                              state s = ‘’
                              on PUT {
                                  s += req.value
                              }
                              on GET {
                                  respond s
                              }
                          }
                   }


                                                      30
Monday, February 27, 12
Università   Faculty
                                                                          della        of Informatics

                                       Example: // Crawler
                                                                          Svizzera
                                                                          Italiana



                   service crawl {
                       res ‘/crawl‘ on PUT {
                           var filter = require(‘HTMLparser.js’).filter
                           res store = ‘/store?value=@’
                                                                            JavaScript
                           res crawl = ‘/crawl?list=@’                        import
                              pfor(var i in req.list) {
                                  var list = filter(get req.list[i])
                                  par {                                     External
                                      store.put(list)                      resources
                                      crawl.put(list)
                                  }                                       declaration
                              }
                          }

                          res ‘/store‘ {
                              state s = ‘’
                              on PUT {
                                  s += req.value
                              }
                              on GET {
                                  respond s
                              }
                          }
                   }


                                                      30
Monday, February 27, 12
Università   Faculty
                                                                                  della        of Informatics

                                       Example: // Crawler
                                                                                  Svizzera
                                                                                  Italiana



                   service crawl {
                       res ‘/crawl‘ on PUT {
                           var filter = require(‘HTMLparser.js’).filter
                           res store = ‘/store?value=@’
                                                                                      JavaScript
                           res crawl = ‘/crawl?list=@’                                  import
                              pfor(var i in req.list) {
                                  var list = filter(get req.list[i])
                                  par {                                            External
                                      store.put(list)                             resources
                                      crawl.put(list)
                                  }                                              declaration
                              }
                          }

                          res ‘/store‘ {
                              state s = ‘’                                 Parallel
                              on PUT {
                                  s += req.value                          recursive
                              }                                            crawling
                              on GET {
                                  respond s
                              }
                          }
                   }


                                                      30
Monday, February 27, 12
Università   Faculty
                                                                                  della        of Informatics

                                       Example: // Crawler
                                                                                  Svizzera
                                                                                  Italiana



                   service crawl {
                       res ‘/crawl‘ on PUT {
                           var filter = require(‘HTMLparser.js’).filter
                           res store = ‘/store?value=@’
                                                                                      JavaScript
                           res crawl = ‘/crawl?list=@’                                  import
                              pfor(var i in req.list) {
                                  var list = filter(get req.list[i])
                                  par {                                            External
                                      store.put(list)                             resources
                                      crawl.put(list)
                                  }                                              declaration
                              }
                          }

                          res ‘/store‘ {
                              state s = ‘’                                 Parallel
                              on PUT {
                                  s += req.value                          recursive
                              }                                            crawling
                              on GET {
                                  respond s
                              }                                  Result
                          }                                   accumulation
                   }


                                                      30
Monday, February 27, 12
Università       Faculty
                                                                                della            of Informatics

                                        Crawler Runtime
                                                                                Svizzera
                                                                                Italiana




                          res ‘/crawl’ on PUT {         res ‘/store’ on PUT {
                              // ...                        // ...
                          }                             }




                                                  Worker #1

                                                                           /store
                               /crawl
                                                                                SLR
                                 SLR                                                         S




                                                   31
Monday, February 27, 12
Università       Faculty
                                                                                della            of Informatics

                                        Crawler Runtime
                                                                                Svizzera
                                                                                Italiana




                          res ‘/crawl’ on PUT {         res ‘/store’ on PUT {
                              // ...                        // ...
                          }                             }




                                                  Worker #1

                                                                           /store
                               /crawl
       L = [...]                                                                SLR
                                 SLR                                                         S




                                                   31
Monday, February 27, 12
Università       Faculty
                                                                                della            of Informatics

                                        Crawler Runtime
                                                                                Svizzera
                                                                                Italiana




                          res ‘/crawl’ on PUT {         res ‘/store’ on PUT {
                              // ...                        // ...
                          }                             }


                                                                            /url1
                                                                            /url2
                                                                              ...
                                                  Worker #1

                                                                           /store
                               /crawl
       L = [...]                                                                SLR
                                 SLR                                                         S




                                                   31
Monday, February 27, 12
Università       Faculty
                                                                                della            of Informatics

                                          Crawler Runtime
                                                                                Svizzera
                                                                                Italiana




                          res ‘/crawl’ on PUT {         res ‘/store’ on PUT {
                              // ...                        // ...
                          }                             }


                                                                            /url1
                                                                            /url2
                              L = [...]                                       ...
                                                  Worker #1

                                                                           /store
                               /crawl
       L = [...]                                                                SLR
                                 SLR                                                         S




                                                   31
Monday, February 27, 12
Università       Faculty
                                                                                della            of Informatics

                                          Crawler Runtime
                                                                                Svizzera
                                                                                Italiana




                          res ‘/crawl’ on PUT {         res ‘/store’ on PUT {
                              // ...                        // ...
                          }                             }


                                                                            /url1
                                                                            /url2
                              L = [...]                                       ...
                                                  Worker #1

                                                                           /store
                               /crawl
       L = [...]                                                                SLR
                                 SLR                                                         S




                                                   31
Monday, February 27, 12
Università       Faculty
                                                                                      della            of Informatics

                                          Crawler Runtime
                                                                                      Svizzera
                                                                                      Italiana




                          res ‘/crawl’ on PUT {               res ‘/store’ on PUT {
                              // ...                              // ...
                          }                                   }


                                                                                  /url1
                                                                                  /url2
                              L = [...]                                             ...
                                                  Worker #1

                                                                                 /store
                               /crawl                   ...
       L = [...]                                                                      SLR
                                 SLR                                                               S
                                                  Worker #n-1




                                                   31
Monday, February 27, 12
Università       Faculty
                                                                                      della            of Informatics

                                          Crawler Runtime
                                                                                      Svizzera
                                                                                      Italiana




                          res ‘/crawl’ on PUT {               res ‘/store’ on PUT {
                              // ...                              // ...
                          }                                   }


                                                                                  /url1
                                                                                  /url2
                              L = [...]                                             ...
                                                  Worker #1

                                                                                 /store
                               /crawl                   ...
       L = [...]                                                                      SLR
                                 SLR                                                               S
                                                  Worker #n-1


                                                  Worker #n
                                                                                  /url1
                                                                                  /url2
                                                                                    ...
                                                   31
Monday, February 27, 12
Università   Faculty
                                                          della        of Informatics

                          Crawler Performance (24cores)   Svizzera
                                                          Italiana




                                        32
Monday, February 27, 12
Università   Faculty
                                                della        of Informatics

                          Crawler Performance   Svizzera
                                                Italiana




                                   33
Monday, February 27, 12
Università   Faculty
                                        della        of Informatics

                          Conclusion
                                        Svizzera
                                        Italiana




                          What is S ?




                               34
Monday, February 27, 12
Università   Faculty
                                                               della        of Informatics

                                     Conclusion
                                                               Svizzera
                                                               Italiana




                                     What is S ?


                     Simple language for composing RESTful services
                             Scalable parallel runtime system
                                  JavaScript compatible




                                           34
Monday, February 27, 12
Università   Faculty
                                                               della        of Informatics

                                     Conclusion
                                                               Svizzera
                                                               Italiana




                                     What is S ?


                     Simple language for composing RESTful services
                             Scalable parallel runtime system
                                  JavaScript compatible


              Safe parallelism is possible for scripting stateful Web
                            services if they are RESTful


                                           34
Monday, February 27, 12
Università   Faculty
                                                           della        of Informatics

                                   Conclusion
                                                           Svizzera
                                                           Italiana




                                   Future work

                                 JVM (Rhino Engine)
                            REST + Streaming services
                          Distributed deployment (Cloud)




                                         35
Monday, February 27, 12
Università   Faculty
                                                                                della        of Informatics
                                                                                Svizzera
                                                                                Italiana




                               Thank You

                          http://sosoa.inf.usi.ch/S


                            daniele.bonetta@usi.ch


                                                                             Daniele Bonetta
                                            Achille Peternier, Cesare Pautasso, Walter Binder
                                                                        Faculty of Informatics
                                                                   University of Lugano - USI
                                                                                  Switzerland

                                       36
Monday, February 27, 12

Mais conteúdo relacionado

Destaque

Push-Enabling RESTful Business Processes
Push-Enabling RESTful Business ProcessesPush-Enabling RESTful Business Processes
Push-Enabling RESTful Business ProcessesCesare Pautasso
 
Web of Things - Towards Open and Sharable Networks of Embedded Devices
Web of Things - Towards Open and Sharable Networks of Embedded DevicesWeb of Things - Towards Open and Sharable Networks of Embedded Devices
Web of Things - Towards Open and Sharable Networks of Embedded DevicesVlad Trifa
 
Vlad Trifa - Final PhD Thesis Defense at ETH Zurich
Vlad Trifa - Final PhD Thesis Defense at ETH ZurichVlad Trifa - Final PhD Thesis Defense at ETH Zurich
Vlad Trifa - Final PhD Thesis Defense at ETH ZurichVlad Trifa
 
Graphs, Edges & Nodes: Untangling the Social Web
Graphs, Edges & Nodes: Untangling the Social WebGraphs, Edges & Nodes: Untangling the Social Web
Graphs, Edges & Nodes: Untangling the Social WebConFoo
 
Web of Things Book Launch
Web of Things Book LaunchWeb of Things Book Launch
Web of Things Book LaunchVlad Trifa
 
EVRYTHNG: Concepts, technologies and applications for connecting physical obj...
EVRYTHNG: Concepts, technologies and applications for connecting physical obj...EVRYTHNG: Concepts, technologies and applications for connecting physical obj...
EVRYTHNG: Concepts, technologies and applications for connecting physical obj...EVRYTHNG
 
Web of Things Platforms Tutorial
Web of Things Platforms TutorialWeb of Things Platforms Tutorial
Web of Things Platforms TutorialEVRYTHNG
 
Web of Things - Connecting People and Objects on the Web
Web of Things - Connecting People and Objects on the WebWeb of Things - Connecting People and Objects on the Web
Web of Things - Connecting People and Objects on the WebDominique Guinard
 
5 Years of Web of Things Workshops
5 Years of Web of Things Workshops5 Years of Web of Things Workshops
5 Years of Web of Things WorkshopsDominique Guinard
 
Web of Things Application Architecture
Web of Things Application ArchitectureWeb of Things Application Architecture
Web of Things Application ArchitectureDominique Guinard
 

Destaque (10)

Push-Enabling RESTful Business Processes
Push-Enabling RESTful Business ProcessesPush-Enabling RESTful Business Processes
Push-Enabling RESTful Business Processes
 
Web of Things - Towards Open and Sharable Networks of Embedded Devices
Web of Things - Towards Open and Sharable Networks of Embedded DevicesWeb of Things - Towards Open and Sharable Networks of Embedded Devices
Web of Things - Towards Open and Sharable Networks of Embedded Devices
 
Vlad Trifa - Final PhD Thesis Defense at ETH Zurich
Vlad Trifa - Final PhD Thesis Defense at ETH ZurichVlad Trifa - Final PhD Thesis Defense at ETH Zurich
Vlad Trifa - Final PhD Thesis Defense at ETH Zurich
 
Graphs, Edges & Nodes: Untangling the Social Web
Graphs, Edges & Nodes: Untangling the Social WebGraphs, Edges & Nodes: Untangling the Social Web
Graphs, Edges & Nodes: Untangling the Social Web
 
Web of Things Book Launch
Web of Things Book LaunchWeb of Things Book Launch
Web of Things Book Launch
 
EVRYTHNG: Concepts, technologies and applications for connecting physical obj...
EVRYTHNG: Concepts, technologies and applications for connecting physical obj...EVRYTHNG: Concepts, technologies and applications for connecting physical obj...
EVRYTHNG: Concepts, technologies and applications for connecting physical obj...
 
Web of Things Platforms Tutorial
Web of Things Platforms TutorialWeb of Things Platforms Tutorial
Web of Things Platforms Tutorial
 
Web of Things - Connecting People and Objects on the Web
Web of Things - Connecting People and Objects on the WebWeb of Things - Connecting People and Objects on the Web
Web of Things - Connecting People and Objects on the Web
 
5 Years of Web of Things Workshops
5 Years of Web of Things Workshops5 Years of Web of Things Workshops
5 Years of Web of Things Workshops
 
Web of Things Application Architecture
Web of Things Application ArchitectureWeb of Things Application Architecture
Web of Things Application Architecture
 

Mais de Cesare Pautasso

Beautiful APIs - SOSE2021 Keynote
Beautiful APIs - SOSE2021 KeynoteBeautiful APIs - SOSE2021 Keynote
Beautiful APIs - SOSE2021 KeynoteCesare Pautasso
 
How do you back up and consistently recover your microservice architecture?
How do you back up and consistently recover your microservice architecture?How do you back up and consistently recover your microservice architecture?
How do you back up and consistently recover your microservice architecture?Cesare Pautasso
 
Microservices: An Eventually Inconsistent Architectural Style?
Microservices: An Eventually Inconsistent Architectural Style?Microservices: An Eventually Inconsistent Architectural Style?
Microservices: An Eventually Inconsistent Architectural Style?Cesare Pautasso
 
Disaster Recovery and Microservices: The BAC Theorem
Disaster Recovery and Microservices: The BAC TheoremDisaster Recovery and Microservices: The BAC Theorem
Disaster Recovery and Microservices: The BAC TheoremCesare Pautasso
 
The Blockchain as a Software Connector
The Blockchain as a Software ConnectorThe Blockchain as a Software Connector
The Blockchain as a Software ConnectorCesare Pautasso
 
Team Situational Awareness and Architectural Decision Making with the Softwar...
Team Situational Awareness and Architectural Decision Making with the Softwar...Team Situational Awareness and Architectural Decision Making with the Softwar...
Team Situational Awareness and Architectural Decision Making with the Softwar...Cesare Pautasso
 
Atomic Transactions for the REST of us
Atomic Transactions for the REST of usAtomic Transactions for the REST of us
Atomic Transactions for the REST of usCesare Pautasso
 
Service Oriented Architectures and Web Services
Service Oriented Architectures and Web ServicesService Oriented Architectures and Web Services
Service Oriented Architectures and Web ServicesCesare Pautasso
 
Exploiting Multicores to Optimize Business Process Execution
Exploiting Multicores to Optimize Business Process ExecutionExploiting Multicores to Optimize Business Process Execution
Exploiting Multicores to Optimize Business Process ExecutionCesare Pautasso
 
Real-time Mashups di Web Service Geografici
Real-time Mashups di Web Service GeograficiReal-time Mashups di Web Service Geografici
Real-time Mashups di Web Service GeograficiCesare Pautasso
 
Towards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresTowards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresCesare Pautasso
 
WS-* vs. RESTful Services
WS-* vs. RESTful ServicesWS-* vs. RESTful Services
WS-* vs. RESTful ServicesCesare Pautasso
 
RESTful Service Composition with JOpera
RESTful Service Composition with JOperaRESTful Service Composition with JOpera
RESTful Service Composition with JOperaCesare Pautasso
 
USI SCUBE Associate Member
USI SCUBE Associate MemberUSI SCUBE Associate Member
USI SCUBE Associate MemberCesare Pautasso
 
Lighweight Collaboration Management (Mashups09@OOPSLA)
Lighweight Collaboration Management (Mashups09@OOPSLA)Lighweight Collaboration Management (Mashups09@OOPSLA)
Lighweight Collaboration Management (Mashups09@OOPSLA)Cesare Pautasso
 
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009Cesare Pautasso
 

Mais de Cesare Pautasso (20)

Beautiful APIs - SOSE2021 Keynote
Beautiful APIs - SOSE2021 KeynoteBeautiful APIs - SOSE2021 Keynote
Beautiful APIs - SOSE2021 Keynote
 
How do you back up and consistently recover your microservice architecture?
How do you back up and consistently recover your microservice architecture?How do you back up and consistently recover your microservice architecture?
How do you back up and consistently recover your microservice architecture?
 
Microservices: An Eventually Inconsistent Architectural Style?
Microservices: An Eventually Inconsistent Architectural Style?Microservices: An Eventually Inconsistent Architectural Style?
Microservices: An Eventually Inconsistent Architectural Style?
 
Disaster Recovery and Microservices: The BAC Theorem
Disaster Recovery and Microservices: The BAC TheoremDisaster Recovery and Microservices: The BAC Theorem
Disaster Recovery and Microservices: The BAC Theorem
 
The Blockchain as a Software Connector
The Blockchain as a Software ConnectorThe Blockchain as a Software Connector
The Blockchain as a Software Connector
 
Team Situational Awareness and Architectural Decision Making with the Softwar...
Team Situational Awareness and Architectural Decision Making with the Softwar...Team Situational Awareness and Architectural Decision Making with the Softwar...
Team Situational Awareness and Architectural Decision Making with the Softwar...
 
BPMN for REST
BPMN for RESTBPMN for REST
BPMN for REST
 
SOA with REST
SOA with RESTSOA with REST
SOA with REST
 
Atomic Transactions for the REST of us
Atomic Transactions for the REST of usAtomic Transactions for the REST of us
Atomic Transactions for the REST of us
 
Service Oriented Architectures and Web Services
Service Oriented Architectures and Web ServicesService Oriented Architectures and Web Services
Service Oriented Architectures and Web Services
 
Exploiting Multicores to Optimize Business Process Execution
Exploiting Multicores to Optimize Business Process ExecutionExploiting Multicores to Optimize Business Process Execution
Exploiting Multicores to Optimize Business Process Execution
 
Real-time Mashups di Web Service Geografici
Real-time Mashups di Web Service GeograficiReal-time Mashups di Web Service Geografici
Real-time Mashups di Web Service Geografici
 
Towards Scalable Service Composition on Multicores
Towards Scalable Service Composition on MulticoresTowards Scalable Service Composition on Multicores
Towards Scalable Service Composition on Multicores
 
BPM with REST
BPM with RESTBPM with REST
BPM with REST
 
WS-* vs. RESTful Services
WS-* vs. RESTful ServicesWS-* vs. RESTful Services
WS-* vs. RESTful Services
 
RESTful Service Composition with JOpera
RESTful Service Composition with JOperaRESTful Service Composition with JOpera
RESTful Service Composition with JOpera
 
SOA2010 SOA with REST
SOA2010 SOA with RESTSOA2010 SOA with REST
SOA2010 SOA with REST
 
USI SCUBE Associate Member
USI SCUBE Associate MemberUSI SCUBE Associate Member
USI SCUBE Associate Member
 
Lighweight Collaboration Management (Mashups09@OOPSLA)
Lighweight Collaboration Management (Mashups09@OOPSLA)Lighweight Collaboration Management (Mashups09@OOPSLA)
Lighweight Collaboration Management (Mashups09@OOPSLA)
 
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
Some REST Design Patterns (and Anti-Patterns) - SOA Symposium 2009
 

Último

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 

S: a Scripting Language for High-Performance RESTful Web Services

  • 1. Università Faculty della of Informatics Svizzera Italiana S A Scripting Language for High-Performance RESTful Web Services Daniele Bonetta Achille Peternier, Cesare Pautasso, Walter Binder Faculty of Informatics University of Lugano - USI Switzerland http://sosoa.inf.usi.ch/s 1 Monday, February 27, 12
  • 2. Università Faculty della of Informatics RESTful Web Services Svizzera Italiana Services using the HTTP protocol HTTP HTTP HTTP Client Client Client REST Architectural Style Client-Server Architecture Stateless Interaction Resources (Stateful, URIs) RESTful service Uniform Interface (GET,PUT,DELETE,POST, ...) resource resource resource resource 2 Monday, February 27, 12
  • 3. Università Faculty della of Informatics Goal Svizzera Italiana Develop and compose RESTful services that scale 3 Monday, February 27, 12
  • 4. Università Faculty della of Informatics Goal Svizzera Italiana Develop and compose RESTful services that scale #clients 3 Monday, February 27, 12
  • 5. Università Faculty della of Informatics Goal Svizzera Italiana Develop and compose RESTful services that scale #clients #cores 3 Monday, February 27, 12
  • 6. Università Faculty della of Informatics Goal Svizzera Italiana Develop and compose RESTful services that scale #clients #cores using safe implicit parallelism 3 Monday, February 27, 12
  • 7. Università Faculty della of Informatics Node.JS Svizzera Italiana Asynchronous Event-loop based solution 4 Monday, February 27, 12
  • 8. Università Faculty della of Informatics Node.JS Svizzera Italiana Asynchronous Event-loop based solution on(‘request’, function(req,res) { // ... }) on(‘response’, function(req,res) { // ... }) 4 Monday, February 27, 12
  • 9. Università Faculty della of Informatics Node.JS Svizzera Italiana Asynchronous Event-loop based solution on(‘request’, function(req,res) { // ... }) on(‘response’, function(req,res) { // ... }) Asynchronous nonblocking I/O ✔ 4 Monday, February 27, 12
  • 10. Università Faculty della of Informatics Node.JS Svizzera Italiana Asynchronous Event-loop based solution on(‘request’, function(req,res) { // ... }) on(‘response’, function(req,res) { // ... }) Asynchronous nonblocking I/O ✔ No locks/synchronization ✔ 4 Monday, February 27, 12
  • 11. Università Faculty della of Informatics Node.JS Svizzera Italiana Asynchronous Event-loop based solution on(‘request’, function(req,res) { // ... }) on(‘response’, function(req,res) { // ... }) Asynchronous nonblocking I/O ✔ No locks/synchronization ✔ Sequential composition: nested callbacks ✘ 4 Monday, February 27, 12
  • 12. Università Faculty della of Informatics Node.JS Svizzera Italiana Asynchronous Event-loop based solution on(‘request’, function(req,res) { // ... }) on(‘response’, function(req,res) { // ... }) Asynchronous nonblocking I/O ✔ No locks/synchronization ✔ Sequential composition: nested callbacks ✘ Callbacks need to be short: never block ✘ 4 Monday, February 27, 12
  • 13. Università Faculty della of Informatics Node.JS Svizzera Italiana Asynchronous Event-loop based solution on(‘request’, function(req,res) { // ... }) on(‘response’, function(req,res) { // ... }) Asynchronous nonblocking I/O ✔ No locks/synchronization ✔ Sequential composition: nested callbacks ✘ Callbacks need to be short: never block ✘ Master worker parallelism ✘ 4 Monday, February 27, 12
  • 14. Università Faculty della of Informatics Svizzera Italiana The S Scripting Language A DSL for RESTful Web Services Development and Composition 5 Monday, February 27, 12
  • 15. Università Faculty della of Informatics Svizzera Italiana S erv ices S tate ful The S Scripting Language A DSL for RESTful Web Services Development and Composition 5 Monday, February 27, 12
  • 16. Università Faculty della of Informatics Svizzera Italiana ab le ca l S erv ices teful S Sta The S Scripting Language A DSL for RESTful Web Services Development and Composition 5 Monday, February 27, 12
  • 17. Università Faculty della of Informatics S: Design Principles Svizzera Italiana High-level architectural abstractions Simple, clean programming model 6 Monday, February 27, 12
  • 18. Università Faculty della of Informatics S: Design Principles Svizzera Italiana High-level architectural abstractions Services compose resources No threads/processes, no synchronization/locks Stateful services Simple, clean programming model 6 Monday, February 27, 12
  • 19. Università Faculty della of Informatics S: Design Principles Svizzera Italiana High-level architectural abstractions Services compose resources No threads/processes, no synchronization/locks Stateful services Simple, clean programming model Allow blocking function calls Synchronous I/O + parallel constructs Uniform interface and URIs 6 Monday, February 27, 12
  • 20. Università Faculty della of Informatics S: Architecture Svizzera Italiana S service 7 Monday, February 27, 12
  • 21. Università Faculty della of Informatics S: Architecture Svizzera Italiana S service S resource S resource S resource 7 Monday, February 27, 12
  • 22. Università Faculty della of Informatics S: Architecture Svizzera Italiana S service S resource S resource S resource Node Node Node Node Node .JS .JS .JS .JS .JS 7 Monday, February 27, 12
  • 23. Università Faculty della of Informatics S: Architecture Svizzera Italiana S service S resource S resource S resource Node Node Node Node Node .JS .JS .JS .JS .JS S IPC Communication framework 7 Monday, February 27, 12
  • 24. Università Faculty della of Informatics S: Architecture Svizzera Italiana S service S resource S resource S resource Node Node Node Node Node .JS .JS .JS .JS .JS S IPC Communication framework Nonblocking I/O 7 Monday, February 27, 12
  • 25. Università Faculty della of Informatics S: Architecture Svizzera Italiana S service Synchronous blocking S resource S resource S resource S code Node Node Node Node Node .JS .JS .JS .JS .JS S IPC Communication framework Nonblocking I/O 7 Monday, February 27, 12
  • 26. Università Faculty della of Informatics S: Architecture Svizzera Italiana S service Synchronous blocking S resource S resource S resource S code Node Node Node Node Node .JS .JS .JS .JS .JS Asynchronous nonblocking S IPC Communication framework Node.JS code Nonblocking I/O 7 Monday, February 27, 12
  • 27. Università Faculty della of Informatics S: Architecture Svizzera Italiana S service No processes/threads S resource S resource S resource locks/sync Node Node Node Node Node .JS .JS .JS .JS .JS Multiple Node.JS processes S IPC Communication framework (IPC + shared state) Nonblocking I/O 8 Monday, February 27, 12
  • 28. Università Faculty della of Informatics Hello S Svizzera Italiana res ‘/hello’ on GET { respond ‘World!’ } 9 Monday, February 27, 12
  • 29. Università Faculty della of Informatics Hello S Svizzera Italiana Request Handler res ‘/hello’ on GET { respond ‘World!’ } 9 Monday, February 27, 12
  • 30. Università Faculty della of Informatics Hello S Svizzera Italiana URI Request Handler res ‘/hello’ on GET { respond ‘World!’ } 9 Monday, February 27, 12
  • 31. Università Faculty della of Informatics Hello S Svizzera Italiana URI HTTP Verb Request Handler res ‘/hello’ on GET { respond ‘World!’ } 9 Monday, February 27, 12
  • 32. Università Faculty della of Informatics Hello S Svizzera Italiana URI HTTP Verb Request Handler res ‘/hello’ on GET { respond ‘World!’ } Any valid JavaScript statement + S specific constructs 9 Monday, February 27, 12
  • 33. Università Faculty della of Informatics Hello S Svizzera Italiana res ‘/hello’ on GET { respond ‘World!’ } HTTP S Client Service 10 Monday, February 27, 12
  • 34. Università Faculty della of Informatics Hello S Svizzera Italiana res ‘/hello’ on GET { respond ‘World!’ } HTTP S Client Service GET /hello HTTP/1.1 User-Agent: curl Accept: */* Host: your.host 10 Monday, February 27, 12
  • 35. Università Faculty della of Informatics Hello S Svizzera Italiana res ‘/hello’ on GET { respond ‘World!’ } HTTP S Client Service HTTP/1.1 200 OK Content-Type: text/plain World! 11 Monday, February 27, 12
  • 36. Università Faculty della of Informatics Compositions Svizzera Italiana res ‘/hello1’ on GET { respond get ‘http://www.a.b’ } res ‘/hello2’ on GET { respond get ‘/hello1’ } 12 Monday, February 27, 12
  • 37. Università Faculty della of Informatics Compositions Svizzera Italiana res ‘/hello1’ on GET { respond get ‘http://www.a.b’ } res ‘/hello2’ on GET { respond get ‘/hello1’ } Native HTTP support 12 Monday, February 27, 12
  • 38. Università Faculty della of Informatics Compositions Svizzera Italiana res ‘/hello1’ on GET { respond get ‘http://www.a.b’ } res ‘/hello2’ on GET { respond get ‘/hello1’ } HTTP Client 13 Monday, February 27, 12
  • 39. Università Faculty della of Informatics Compositions Svizzera Italiana res ‘/hello1’ on GET { respond get ‘http://www.a.b’ } res ‘/hello2’ on GET { respond get ‘/hello1’ } HTTP /hello2 Client 13 Monday, February 27, 12
  • 40. Università Faculty della of Informatics Compositions Svizzera Italiana res ‘/hello1’ on GET { respond get ‘http://www.a.b’ } res ‘/hello2’ on GET { respond get ‘/hello1’ } HTTP /hello2 /hello1 Client 13 Monday, February 27, 12
  • 41. Università Faculty della of Informatics Compositions Svizzera Italiana res ‘/hello1’ on GET { respond get ‘http://www.a.b’ } res ‘/hello2’ on GET { respond get ‘/hello1’ } HTTP /hello2 /hello1 www.a.b Client 13 Monday, February 27, 12
  • 42. Università Faculty della of Informatics Compositions Svizzera Italiana res ‘/hello1’ on GET { respond get ‘http://www.a.b’ } res ‘/hello2’ on GET { respond get ‘/hello1’ } HTTP /hello2 /hello1 www.a.b Client 13 Monday, February 27, 12
  • 43. Università Faculty della of Informatics Concurrency & Parallelism Svizzera Italiana res ‘/res1‘ on GET { // ... // CPU/bound blocking call var a = foo() respond a } res ‘/res2’ on GET { // ... res r = ‘http://www.google.ch/search=@’ // I/O bound operation boo = r.get(‘key’) respond boo } 14 Monday, February 27, 12
  • 44. Università Faculty della of Informatics Concurrency & Parallelism Svizzera Italiana res ‘/res1‘ on GET { // ... Atomically // CPU/bound blocking call executed var a = foo() blocks respond a } res ‘/res2’ on GET { // ... res r = ‘http://www.google.ch/search=@’ // I/O bound operation boo = r.get(‘key’) respond boo } 14 Monday, February 27, 12
  • 45. Università Faculty della of Informatics Concurrency & Parallelism Svizzera Italiana res ‘/res1‘ on GET { // ... // CPU/bound blocking call Parallel var a = foo() resources respond a } res ‘/res2’ on GET { // ... res r = ‘http://www.google.ch/search=@’ // I/O bound operation boo = r.get(‘key’) respond boo } 15 Monday, February 27, 12
  • 46. Università Faculty della of Informatics Concurrency & Parallelism Svizzera Italiana res ‘/res1‘ on GET { // ... // CPU/bound blocking call Synchronous var a = foo() operations respond a } res ‘/res2’ on GET { // ... res r = ‘http://www.google.ch/search=@’ // I/O bound operation boo = r.get(‘key’) respond boo } 16 Monday, February 27, 12
  • 47. Università Faculty della of Informatics (1) CPU-bound Operations Svizzera Italiana Request Handler Processor /res Worker #1 Router Worker #n 17 Monday, February 27, 12
  • 48. Università Faculty della of Informatics (1) CPU-bound Operations Svizzera Italiana Request Handler Processor /res Worker #1 Router Worker #n 17 Monday, February 27, 12
  • 49. Università Faculty della of Informatics (1) CPU-bound Operations Svizzera Italiana Request Handler Processor /res Worker #1 To clients (HTTP response) Router Worker #n From clients (HTTP requests) 17 Monday, February 27, 12
  • 50. Università Faculty della of Informatics (1) CPU-bound Operations Svizzera Italiana (2) I/O-bound Operations Request Handler Processor /res Worker #1 To clients (HTTP response) Router Worker #n From clients Parallelism degree (HTTP requests) controller (PI) 17 Monday, February 27, 12
  • 51. Università Faculty della of Informatics (1) CPU-bound Operations Svizzera Italiana (2) I/O-bound Operations To external resources Request Handler Processor (through HTTP) From other workers /res Worker #1 To clients (HTTP response) Router Worker #n To internal resources (through IPC) From clients Parallelism degree (HTTP requests) controller (PI) 17 Monday, February 27, 12
  • 52. Università Faculty della of Informatics (2) I/O-bound Operations Svizzera Italiana Event-based compilation output targeting Node.JS 18 Monday, February 27, 12
  • 53. Università Faculty della of Informatics (2) I/O-bound Operations Svizzera Italiana Event-based compilation output targeting Node.JS • Synchronous I/O operations are desynchronized by the compiler using multiple callbacks 18 Monday, February 27, 12
  • 54. Università Faculty della of Informatics (2) I/O-bound Operations Svizzera Italiana Event-based compilation output targeting Node.JS • Synchronous I/O operations are desynchronized by the compiler using multiple callbacks • Callbacks are scheduled by the runtime using an event-based approach. 18 Monday, February 27, 12
  • 55. Università Faculty della of Informatics Sync to Async Compilation Svizzera Italiana S vs. Node.JS res ‘/example’ on GET { var a = get ‘www.google.com’ var b = get ‘www.bing.com’ var c = get ‘www.yahoo.com’ respond a+b+c } 19 Monday, February 27, 12
  • 56. Università Faculty della of Informatics Sync to Async Compilation Svizzera Italiana S vs. Node.JS res ‘/example’ on GET { http.createServer(function(creq,cres){ var a = get ‘www.google.com’ if(creq.method==‘GET’&&creq.url==‘/example’) { var b = get ‘www.bing.com’ var a,b,c = ‘’ var c = get ‘www.yahoo.com’ respond a+b+c startGet(‘www.google.com’, } function(req,res) { a = res.body startGet(‘www.bing.com’, function(req,res) { b = res.body startGet(‘www.yahoo.com’, function(req,res) { c = res.body cres.end(a+b+c) }) }) }) } }) 19 Monday, February 27, 12
  • 57. Università Faculty della of Informatics Sync to Async Compilation Svizzera Italiana S vs. Node.JS res ‘/example’ on GET { par { var a = get ‘www.google.com’ var b = get ‘www.bing.com’ var c = put ‘www.a.b/?d=’+b respond a+c }} 20 Monday, February 27, 12
  • 58. Università Faculty della of Informatics Sync to Async Compilation Svizzera Italiana S vs. Node.JS res ‘/example’ on GET { http.createServer(function(req,res) { par { if(creq.method==‘GET’&&creq.url==‘/example’) { var a = get ‘www.google.com’ var G = {} var b = get ‘www.bing.com’ var c = put ‘www.a.b/?d=’+b on(‘done1’, function(result){ respond a+c G.a = result; emit(‘done3’)}) }} on(‘done2’, function(result){ G.b = result; get get startPut(‘www.a.b/d?=‘+G.b, ‘done4’) }) on(‘done4’, function(result) { var b = ... G.c = result; emit(‘done5’) var a = ... }) put onAll([‘done3’,‘done5’], function() { res.end(G.a+G.c) var c = ... }) startGet(‘www.google.com’, ‘done1’) startGet(‘www.bing.com’, ‘done2’) respond } }) 20 Monday, February 27, 12
  • 59. Università Faculty della of Informatics Sync to Async Compilation Svizzera Italiana http.createServer(function(req,res) { if(creq.method==‘GET’&&creq.url==‘/example’) { var G = {} on(‘done1’, function(result){ get get G.a = result; emit(‘done3’)}) on(‘done2’, function(result){ var b G.b = result; startPut(‘www.a.b/d?=‘+G.b, ‘done4’) var a }) put on(‘done4’, function(result) { G.c = result; var c emit(‘done5’) }) respond onAll([‘done3’,‘done5’], function() { res.end(G.a+G.c) }) startGet(‘www.google.com’, ‘done1’) startGet(‘www.bing.com’, ‘done2’) } }) 21 Monday, February 27, 12
  • 60. Università Faculty della of Informatics Sync to Async Compilation Svizzera Italiana Callbacks registration http.createServer(function(req,res) { if(creq.method==‘GET’&&creq.url==‘/example’) { var G = {} on(‘done1’, function(result){ get get G.a = result; emit(‘done3’)}) on(‘done2’, function(result){ var b G.b = result; startPut(‘www.a.b/d?=‘+G.b, ‘done4’) var a }) put on(‘done4’, function(result) { G.c = result; var c emit(‘done5’) }) respond onAll([‘done3’,‘done5’], function() { res.end(G.a+G.c) }) startGet(‘www.google.com’, ‘done1’) startGet(‘www.bing.com’, ‘done2’) } }) 21 Monday, February 27, 12
  • 61. Università Faculty della of Informatics Sync to Async Compilation Svizzera Italiana Callbacks registration http.createServer(function(req,res) { if(creq.method==‘GET’&&creq.url==‘/example’) { var G = {} on(‘done1’, function(result){ get get G.a = result; emit(‘done3’)}) on(‘done2’, function(result){ var b G.b = result; startPut(‘www.a.b/d?=‘+G.b, ‘done4’) var a }) put on(‘done4’, function(result) { G.c = result; var c emit(‘done5’) }) respond onAll([‘done3’,‘done5’], function() { res.end(G.a+G.c) }) startGet(‘www.google.com’, ‘done1’) startGet(‘www.bing.com’, ‘done2’) } }) 21 Monday, February 27, 12
  • 62. Università Faculty della of Informatics Sync to Async Compilation Svizzera Italiana http.createServer(function(req,res) { if(creq.method==‘GET’&&creq.url==‘/example’) { var G = {} on(‘done1’, function(result){ get get G.a = result; emit(‘done3’)}) on(‘done2’, function(result){ var b G.b = result; startPut(‘www.a.b/d?=‘+G.b, ‘done4’) var a }) put on(‘done4’, function(result) { G.c = result; var c emit(‘done5’) }) respond onAll([‘done3’,‘done5’], function() { res.end(G.a+G.c) }) startGet(‘www.google.com’, ‘done1’) startGet(‘www.bing.com’, ‘done2’) } }) 22 Monday, February 27, 12
  • 63. Università Faculty della of Informatics Sync to Async Compilation Svizzera Italiana http.createServer(function(req,res) { if(creq.method==‘GET’&&creq.url==‘/example’) { var G = {} on(‘done1’, function(result){ get get G.a = result; emit(‘done3’)}) on(‘done2’, function(result){ var b G.b = result; startPut(‘www.a.b/d?=‘+G.b, ‘done4’) var a }) put on(‘done4’, function(result) { G.c = result; var c emit(‘done5’) }) respond onAll([‘done3’,‘done5’], function() { res.end(G.a+G.c) }) startGet(‘www.google.com’, ‘done1’) startGet(‘www.bing.com’, ‘done2’) } }) 23 Monday, February 27, 12
  • 64. Università Faculty della of Informatics Sync to Async Compilation Svizzera Italiana http.createServer(function(req,res) { if(creq.method==‘GET’&&creq.url==‘/example’) { var G = {} on(‘done1’, function(result){ get get G.a = result; emit(‘done3’)}) on(‘done2’, function(result){ var b G.b = result; startPut(‘www.a.b/d?=‘+G.b, ‘done4’) var a }) put on(‘done4’, function(result) { G.c = result; var c emit(‘done5’) }) respond onAll([‘done3’,‘done5’], function() { res.end(G.a+G.c) }) startGet(‘www.google.com’, ‘done1’) startGet(‘www.bing.com’, ‘done2’) } }) 23 Monday, February 27, 12
  • 65. Università Faculty della of Informatics Other Constructs Svizzera Italiana pfor res creation res ‘/pfor’ on GET { res ‘/example’ { var L = [1,2,3] state s = 0 var a = ‘’ on POST { res r = ‘www.a.b/val=@’ s++ pfor (var i in L) { res ‘/newResource’+s { a += r.get(L[i]) on GET { respond s } } on DELETE {} respond a } } } } } 24 Monday, February 27, 12
  • 66. Università Faculty della of Informatics Stateful Services Svizzera Italiana res ‘/helloState’ { state s = ‘world’ on GET { respond ‘hello’ + s } on PUT { s = req.name } } 25 Monday, February 27, 12
  • 67. Università Faculty della of Informatics Stateful Services Svizzera Italiana res ‘/helloState’ { state s = ‘world’ Shared state on GET { respond ‘hello’ + s } on PUT { s = req.name } } 25 Monday, February 27, 12
  • 68. Università Faculty della of Informatics Stateful Services Svizzera Italiana res ‘/helloState’ { state s = ‘world’ Shared state on GET { respond ‘hello’ + s Read-only operations } on PUT { s = req.name } } 25 Monday, February 27, 12
  • 69. Università Faculty della of Informatics Stateful Services Svizzera Italiana res ‘/helloState’ { state s = ‘world’ Shared state on GET { respond ‘hello’ + s Read-only operations } on PUT { s = req.name } Write operation } 25 Monday, February 27, 12
  • 70. Università Faculty della of Informatics Uniform Interface and Parallelism Svizzera Italiana HTTP’s Uniform Interface HTTP Verb Properties Parallelism HTTP GET Idempotent, safe, Yes stateless HTTP PUT Idempotent, Side- If stateless effects HTTP DELETE Idempotent, Side- If stateless effects HTTP POST Side-effects If stateless 26 Monday, February 27, 12
  • 71. Università Faculty della of Informatics Versioned State Management Svizzera Italiana res ‘/res’ state s Guarantees: on GET { } // read s • Eventual (C)onsistency on PUT { • (A)vailability } // alter s • (P)artition Tolerance } S V. n Worker #1 SLR Worker #n S V. n S V. n 27 Monday, February 27, 12
  • 72. Università Faculty della of Informatics Versioned State Management Svizzera Italiana res ‘/res’ state s Guarantees: on GET { } // read s • Eventual (C)onsistency on PUT { • (A)vailability } // alter s • (P)artition Tolerance } S V. n Worker #1 GET /res SLR Worker #n S V. n S V. n 27 Monday, February 27, 12
  • 73. Università Faculty della of Informatics Versioned State Management Svizzera Italiana res ‘/res’ state s Guarantees: on GET { } // read s • Eventual (C)onsistency on PUT { • (A)vailability } // alter s • (P)artition Tolerance } V. n-1 S Worker #1 SLR Worker #n S S V. n V. n-1 28 Monday, February 27, 12
  • 74. Università Faculty della of Informatics Versioned State Management Svizzera Italiana res ‘/res’ state s Guarantees: on GET { } // read s • Eventual (C)onsistency on PUT { • (A)vailability } // alter s • (P)artition Tolerance } V. n-1 S Worker #1 PUT /res SLR Worker #n S S V. n V. n-1 28 Monday, February 27, 12
  • 75. Università Faculty della of Informatics Versioned State Management Svizzera Italiana res ‘/res’ state s Guarantees: on GET { } // read s • Eventual (C)onsistency on PUT { • (A)vailability } // alter s • (P)artition Tolerance } S V. n-1 Worker #1 V. n GET /res SLR Worker #n S V. n S V. n-1 29 Monday, February 27, 12
  • 76. Università Faculty della of Informatics Example: // Crawler Svizzera Italiana service crawl { res ‘/crawl‘ on PUT { var filter = require(‘HTMLparser.js’).filter res store = ‘/store?value=@’ res crawl = ‘/crawl?list=@’ pfor(var i in req.list) { var list = filter(get req.list[i]) par { store.put(list) crawl.put(list) } } } res ‘/store‘ { state s = ‘’ on PUT { s += req.value } on GET { respond s } } } 30 Monday, February 27, 12
  • 77. Università Faculty della of Informatics Example: // Crawler Svizzera Italiana service crawl { res ‘/crawl‘ on PUT { var filter = require(‘HTMLparser.js’).filter res store = ‘/store?value=@’ JavaScript res crawl = ‘/crawl?list=@’ import pfor(var i in req.list) { var list = filter(get req.list[i]) par { store.put(list) crawl.put(list) } } } res ‘/store‘ { state s = ‘’ on PUT { s += req.value } on GET { respond s } } } 30 Monday, February 27, 12
  • 78. Università Faculty della of Informatics Example: // Crawler Svizzera Italiana service crawl { res ‘/crawl‘ on PUT { var filter = require(‘HTMLparser.js’).filter res store = ‘/store?value=@’ JavaScript res crawl = ‘/crawl?list=@’ import pfor(var i in req.list) { var list = filter(get req.list[i]) par { External store.put(list) resources crawl.put(list) } declaration } } res ‘/store‘ { state s = ‘’ on PUT { s += req.value } on GET { respond s } } } 30 Monday, February 27, 12
  • 79. Università Faculty della of Informatics Example: // Crawler Svizzera Italiana service crawl { res ‘/crawl‘ on PUT { var filter = require(‘HTMLparser.js’).filter res store = ‘/store?value=@’ JavaScript res crawl = ‘/crawl?list=@’ import pfor(var i in req.list) { var list = filter(get req.list[i]) par { External store.put(list) resources crawl.put(list) } declaration } } res ‘/store‘ { state s = ‘’ Parallel on PUT { s += req.value recursive } crawling on GET { respond s } } } 30 Monday, February 27, 12
  • 80. Università Faculty della of Informatics Example: // Crawler Svizzera Italiana service crawl { res ‘/crawl‘ on PUT { var filter = require(‘HTMLparser.js’).filter res store = ‘/store?value=@’ JavaScript res crawl = ‘/crawl?list=@’ import pfor(var i in req.list) { var list = filter(get req.list[i]) par { External store.put(list) resources crawl.put(list) } declaration } } res ‘/store‘ { state s = ‘’ Parallel on PUT { s += req.value recursive } crawling on GET { respond s } Result } accumulation } 30 Monday, February 27, 12
  • 81. Università Faculty della of Informatics Crawler Runtime Svizzera Italiana res ‘/crawl’ on PUT { res ‘/store’ on PUT { // ... // ... } } Worker #1 /store /crawl SLR SLR S 31 Monday, February 27, 12
  • 82. Università Faculty della of Informatics Crawler Runtime Svizzera Italiana res ‘/crawl’ on PUT { res ‘/store’ on PUT { // ... // ... } } Worker #1 /store /crawl L = [...] SLR SLR S 31 Monday, February 27, 12
  • 83. Università Faculty della of Informatics Crawler Runtime Svizzera Italiana res ‘/crawl’ on PUT { res ‘/store’ on PUT { // ... // ... } } /url1 /url2 ... Worker #1 /store /crawl L = [...] SLR SLR S 31 Monday, February 27, 12
  • 84. Università Faculty della of Informatics Crawler Runtime Svizzera Italiana res ‘/crawl’ on PUT { res ‘/store’ on PUT { // ... // ... } } /url1 /url2 L = [...] ... Worker #1 /store /crawl L = [...] SLR SLR S 31 Monday, February 27, 12
  • 85. Università Faculty della of Informatics Crawler Runtime Svizzera Italiana res ‘/crawl’ on PUT { res ‘/store’ on PUT { // ... // ... } } /url1 /url2 L = [...] ... Worker #1 /store /crawl L = [...] SLR SLR S 31 Monday, February 27, 12
  • 86. Università Faculty della of Informatics Crawler Runtime Svizzera Italiana res ‘/crawl’ on PUT { res ‘/store’ on PUT { // ... // ... } } /url1 /url2 L = [...] ... Worker #1 /store /crawl ... L = [...] SLR SLR S Worker #n-1 31 Monday, February 27, 12
  • 87. Università Faculty della of Informatics Crawler Runtime Svizzera Italiana res ‘/crawl’ on PUT { res ‘/store’ on PUT { // ... // ... } } /url1 /url2 L = [...] ... Worker #1 /store /crawl ... L = [...] SLR SLR S Worker #n-1 Worker #n /url1 /url2 ... 31 Monday, February 27, 12
  • 88. Università Faculty della of Informatics Crawler Performance (24cores) Svizzera Italiana 32 Monday, February 27, 12
  • 89. Università Faculty della of Informatics Crawler Performance Svizzera Italiana 33 Monday, February 27, 12
  • 90. Università Faculty della of Informatics Conclusion Svizzera Italiana What is S ? 34 Monday, February 27, 12
  • 91. Università Faculty della of Informatics Conclusion Svizzera Italiana What is S ? Simple language for composing RESTful services Scalable parallel runtime system JavaScript compatible 34 Monday, February 27, 12
  • 92. Università Faculty della of Informatics Conclusion Svizzera Italiana What is S ? Simple language for composing RESTful services Scalable parallel runtime system JavaScript compatible Safe parallelism is possible for scripting stateful Web services if they are RESTful 34 Monday, February 27, 12
  • 93. Università Faculty della of Informatics Conclusion Svizzera Italiana Future work JVM (Rhino Engine) REST + Streaming services Distributed deployment (Cloud) 35 Monday, February 27, 12
  • 94. Università Faculty della of Informatics Svizzera Italiana Thank You http://sosoa.inf.usi.ch/S daniele.bonetta@usi.ch Daniele Bonetta Achille Peternier, Cesare Pautasso, Walter Binder Faculty of Informatics University of Lugano - USI Switzerland 36 Monday, February 27, 12