SAN FRANCISCO, CA, USADaniele Bonetta Achille PeternierCesare Pautasso Walter Binderhttp://sosoa.inf.unisi.ch
SOSOA                                         Computing in Heterogeneous, Autonomous N Goal-oriented Environments• Self-Or...
RESTful Web Services                                           Computing in Heterogeneous, Autonomous N Goal-oriented Envi...
HTTP uniform interface                                                Computing in Heterogeneous, Autonomous N Goal-orient...
Goal                                        Computing in Heterogeneous, Autonomous N Goal-oriented Environments “Design a ...
RESTful Web   Services              S framework                   Multicore server
RESTful Web          Services                        S languageS compiler                        S runtime                ...
RESTful Web          Services                        S languageS compiler                        S runtime                ...
“Node.js is a platform built on Chromes JavaScriptruntime for easily building fast, scalable networkapplications. Node.js ...
Computing in Heterogeneous, Autonomous N Goal-oriented Environments• Single process• Based on asynchronous event-loop and ...
Computing in Heterogeneous, Autonomous N Goal-oriented Environments• Asynchronous non-blocking I/O ✔• No locks/synchroniza...
S language
S design principles                                        Computing in Heterogeneous, Autonomous N Goal-oriented Environm...
S Architecture                                                  Computing in Heterogeneous, Autonomous N Goal-oriented Env...
S Hello World                                             Computing in Heterogeneous, Autonomous N Goal-oriented Environme...
S Hello World                                              Computing in Heterogeneous, Autonomous N Goal-oriented Environm...
S Hello World                                              Computing in Heterogeneous, Autonomous N Goal-oriented Environm...
S Compositions                                       Computing in Heterogeneous, Autonomous N Goal-oriented Environments  ...
S Compositions                                                  Computing in Heterogeneous, Autonomous N Goal-oriented Env...
S Parallelism                                            Computing in Heterogeneous, Autonomous N Goal-oriented Environmen...
Adaptivity                                               Computing in Heterogeneous, Autonomous N Goal-oriented Environmen...
S compiler
Stateful services                                          Computing in Heterogeneous, Autonomous N Goal-oriented Environm...
I/O-bound operations                                         Computing in Heterogeneous, Autonomous N Goal-oriented Enviro...
Sequential composition                                       Computing in Heterogeneous, Autonomous N Goal-oriented Enviro...
Sequential composition                                       Computing in Heterogeneous, Autonomous N Goal-oriented Enviro...
Parallel composition                                       Computing in Heterogeneous, Autonomous N Goal-oriented Environm...
Parallel composition                                                    Computing in Heterogeneous, Autonomous N Goal-orie...
Parallel composition                                             Computing in Heterogeneous, Autonomous N Goal-oriented En...
Two levels of parallelism                                                 Computing in Heterogeneous, Autonomous N Goal-or...
Example: Crawler                                                         Computing in Heterogeneous, Autonomous N Goal-ori...
Example: Crawler RT                                             Computing in Heterogeneous, Autonomous N Goal-oriented Env...
Crawler performance                                         Computing in Heterogeneous, Autonomous N Goal-oriented Environ...
Challenges                                               Computing in Heterogeneous, Autonomous N Goal-oriented Environmen...
Challenges                                       Computing in Heterogeneous, Autonomous N Goal-oriented EnvironmentsCHANGE...
Challenges                                       Computing in Heterogeneous, Autonomous N Goal-oriented Environments      ...
Challenges                                       Computing in Heterogeneous, Autonomous N Goal-oriented Environments      ...
Thank you                                         Computing in Heterogeneous, Autonomous N Goal-oriented Environmentshttp:...
Upcoming SlideShare
Loading in …5
×

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

1,230 views

Published on

Invited presentation given at DAC Change Workshop 2012 in Moscone Center, San Francisco, California.

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,230
On SlideShare
0
From Embeds
0
Number of Embeds
345
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

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

  1. 1. SAN FRANCISCO, CA, USADaniele Bonetta Achille PeternierCesare Pautasso Walter Binderhttp://sosoa.inf.unisi.ch
  2. 2. SOSOA Computing in Heterogeneous, Autonomous N Goal-oriented Environments• Self-Organizing Service Oriented Architectures• Exploring novel, self-adapting approaches to the design of SOAs• Overcome limitations of current SOAs  performance on modern infrastructures • Multicores • Cloud CHANGE 2012 – San Francisco, CA, USA 2
  3. 3. RESTful Web Services Computing in Heterogeneous, Autonomous N Goal-oriented Environments• Architectural style:  Client/Server architecture  Stateless interaction  Resources Client Client Client • URIs HTTP  Uniform HTTP interface • GET, PUT, POST, DELETE RESTful Web Services Resource Resource Resource Resource CHANGE 2012 – San Francisco, CA, USA 3
  4. 4. HTTP uniform interface Computing in Heterogeneous, Autonomous N Goal-oriented Environments HTTP Method Properties Parallelism Idempotent, safe, GET Yes stateless Idempotent, PUT If stateless side-effects Idempotent, DELETE If stateless side-effects POST side-effects If statelessCHANGE 2012 – San Francisco, CA, USA 4
  5. 5. Goal Computing in Heterogeneous, Autonomous N Goal-oriented Environments “Design a new language to develop and compose RESTful Web Services that automatically scale in the number ofclients using the available cores and safe implicit parallelism” CHANGE 2012 – San Francisco, CA, USA S 5
  6. 6. RESTful Web Services S framework Multicore server
  7. 7. RESTful Web Services S languageS compiler S runtime Multicore server
  8. 8. RESTful Web Services S languageS compiler S runtime Multicore server
  9. 9. “Node.js is a platform built on Chromes JavaScriptruntime for easily building fast, scalable networkapplications. Node.js uses an event-driven, non-blockingI/O model that makes it lightweight and efficient, perfect fordata-intensive real-time applications that run acrossdistributed devices.” (source: www.nodejs.org)
  10. 10. Computing in Heterogeneous, Autonomous N Goal-oriented Environments• Single process• Based on asynchronous event-loop and callbacks on („someEvent‟, doSomething(req, res)) on („somethingElse‟, function(req, res) { // ... })CHANGE 2012 – San Francisco, CA, USA 10
  11. 11. Computing in Heterogeneous, Autonomous N Goal-oriented Environments• Asynchronous non-blocking I/O ✔• No locks/synchronization ✔• Sequential composition: nested callbacks ✘• Problems with long-running callbacks ✘• Limited support for parallelism ✘CHANGE 2012 – San Francisco, CA, USA 11
  12. 12. S language
  13. 13. S design principles Computing in Heterogeneous, Autonomous N Goal-oriented Environments• High-level architectural abstractions  Based on services and resources  No threads/processes • No synchronization/locks• Simple, clean programming model  Allows blocking function calls  Constructs for parallel I/O  REST/HTTP as part of the language CHANGE 2012 – San Francisco, CA, USA 13
  14. 14. S Architecture Computing in Heterogeneous, Autonomous N Goal-oriented Environments S language S Service S code S Resource S Resource S Resource NodeJS NodeJS NodeJS NodeJS NodeJS Asynchronous S IPC Communication Framework Non-blocking NodeJS code Non-blocking I/O S runtimeCHANGE 2012 – San Francisco, CA, USA 14
  15. 15. S Hello World Computing in Heterogeneous, Autonomous N Goal-oriented Environments URI HTTP Resource method res „/hello‟ on GET { respond „World!‟ } JavaScript or S codeCHANGE 2012 – San Francisco, CA, USA 15
  16. 16. S Hello World Computing in Heterogeneous, Autonomous N Goal-oriented Environments res „/hello‟ on GET { respond „World!‟ } S Client HTTP Service GET /hello HTTP/1.1 User-Agent: curl Accept: */* Host: your.hostCHANGE 2012 – San Francisco, CA, USA 16
  17. 17. S Hello World Computing in Heterogeneous, Autonomous N Goal-oriented Environments res „/hello‟ on GET { respond „World!‟ } S Client HTTP Service HTTP/1.1 200 OK Content-Type: text/plain World!CHANGE 2012 – San Francisco, CA, USA 17
  18. 18. S Compositions Computing in Heterogeneous, Autonomous N Goal-oriented Environments res „/hello1‟ on GET { respond get „http://www.site.com‟ } Native HTTP support res „/hello2‟ on GET { respond get „/hello1‟ }CHANGE 2012 – San Francisco, CA, USA 18
  19. 19. S Compositions Computing in Heterogeneous, Autonomous N Goal-oriented Environments res „/hello1‟ on GET { respond get „http://www.site.com‟ }Client HTTP /hello2 HTTP /hello1 HTTP www.site.com res „/hello2‟ on GET { respond get „/hello1‟ } CHANGE 2012 – San Francisco, CA, USA 19
  20. 20. S Parallelism Computing in Heterogeneous, Autonomous N Goal-oriented Environments res „/res1‟ on GET { // ... Parallel // CPU-bound blocking call: resources var a = foo() respond a } res „/res2‟ on GET { // ... res r = „http://www.google.ch/search=@‟ Atomic and // I/O bound operation: boo = r.get(„key‟) consistent respond boo blocks } CHANGE 2012 – San Francisco, CA, USA 20
  21. 21. Adaptivity Computing in Heterogeneous, Autonomous N Goal-oriented EnvironmentsFrom otherworkers Request handler processor S S Worker S Responses WorkerWorker Worker #1 HTTP ClientRequests /res Client Client Client Client HTTP Router …Client Worker #n Parallelism degree controller (PI) CHANGE 2012 – San Francisco, CA, USA 21
  22. 22. S compiler
  23. 23. Stateful services Computing in Heterogeneous, Autonomous N Goal-oriented Environments State shared res „/helloState‟ { between state s = „world‟ callbacks on GET { respond „hello‟ + s Read-only } operations on PUT { s = req.name } Write } operations CHANGE 2012 – San Francisco, CA, USA 23
  24. 24. I/O-bound operations Computing in Heterogeneous, Autonomous N Goal-oriented Environments• Synchronous I/O operations are desynchronized by the S compiler using multiple callbacks CHANGE 2012 – San Francisco, CA, USA 24
  25. 25. Sequential composition Computing in Heterogeneous, Autonomous N Goal-oriented Environments 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 }CHANGE 2012 – San Francisco, CA, USA S 25
  26. 26. Sequential composition Computing in Heterogeneous, Autonomous N Goal-oriented Environments http.createServer(function(creq, cres) { if (creq.method == „GET‟ && creq.url == „/example‟) { var a, b, c = „‟ startGet(„www.google.com‟, function(req, res) { a = res.body startGet(„www.bing.com‟, function(req, res) { S b = res.body startGet(„www.yahoo.com‟, function(req, res) { c = res.body cres.end(a+b+c) }) }) }) } })CHANGE 2012 – San Francisco, CA, USA 26
  27. 27. Parallel composition Computing in Heterogeneous, Autonomous N Goal-oriented Environments res „/example‟ on GET { par { var a = get „www.google.com‟ var b = get „www.bing.com‟ var c = put „www.site.com/?d=‟+b respond a+c } S }CHANGE 2012 – San Francisco, CA, USA 27
  28. 28. Parallel composition Computing in Heterogeneous, Autonomous N Goal-oriented Environments get get var a=… var b=…res „/example‟ on GET { put par { var a = get „www.google.com‟ var b = get „www.bing.com‟ var c = put „www.site.com/?d=‟+b var c=… respond a+c }} respond CHANGE 2012 – San Francisco, CA, USA 28
  29. 29. Parallel composition Computing in Heterogeneous, Autonomous N Goal-oriented Environmentshttp.createServer(function(req, res) { if (creq.method == „GET‟ && creq.url == „/example‟) { var G = {} on („done1‟, function(result) { G.a = result; emit(„done3‟) }) on („done2‟, function(result) { G.b = result; startPut(„www.site.com./d?=„ + G.b, „done4‟) S }) on („done4‟, function(result) { G.c = result; emit(„done5‟) }) onAll([„done3‟,„done5‟], function() { res.end(G.a + G.c) }) startGet(„www.google.com‟, „done1‟) startGet(„www.bing.com‟, „done2‟) }}) CHANGE 2012 – San Francisco, CA, USA 29
  30. 30. Two levels of parallelism Computing in Heterogeneous, Autonomous N Goal-oriented Environments e.g.: travel Async I/O agencyI/O-bound e.g.: Fibonacci series Number of Workers CPU-bound CHANGE 2012 – San Francisco, CA, USA 30
  31. 31. Example: Crawler Computing in Heterogeneous, Autonomous N Goal-oriented Environments 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) { Parallel var list = filter(get req.list[i]) recursive par { crawling store.put(list) crawl.put(list) } } } res „/store„ { state s = „‟ on PUT { s += req.value Result } on GET { accumulation respond s } } }CHANGE 2012 – San Francisco, CA, USA 31
  32. 32. Example: Crawler RT Computing in Heterogeneous, Autonomous N Goal-oriented Environments /url /url /url Worker #1 /crawl Worker #2 L=[url1, url2, …] Router … Worker #n /store Router State CHANGE 2012 – San Francisco, CA, USA 32
  33. 33. Crawler performance Computing in Heterogeneous, Autonomous N Goal-oriented Environments 24 cores serverCHANGE 2012 – San Francisco, CA, USA 33
  34. 34. Challenges Computing in Heterogeneous, Autonomous N Goal-oriented Environments Worker #1 /res Router … Worker #n Monitor and Worker #1 controller Worker #1/res /res Router … Router … Worker #n Worker #n Monitor and CPU I/O Monitor and controller controllerCHANGE 2012 – San Francisco, CA, USA 34
  35. 35. Challenges Computing in Heterogeneous, Autonomous N Goal-oriented EnvironmentsCHANGE 2012 – San Francisco, CA, USA 35
  36. 36. Challenges Computing in Heterogeneous, Autonomous N Goal-oriented Environments Client HTTPCHANGE 2012 – San Francisco, CA, USA 36
  37. 37. Challenges Computing in Heterogeneous, Autonomous N Goal-oriented Environments ClientCHANGE 2012 – San Francisco, CA, USA 37
  38. 38. Thank you Computing in Heterogeneous, Autonomous N Goal-oriented Environmentshttp://sosoa.inf.unisi.chD. Bonetta, A. Peternier, C. Pautasso, W. BinderS: a Scripting Language for High-Performance RESTful WebServices17th ACM SIGPLAN Symposium on Principles and Practice of ParallelProgramming (PPoPP 2012), pp. 97-106, New Orleans, LA, USA, 2012 CHANGE 2012 – San Francisco, CA, USA S 38

×