Presentation of the paper:
D. Bonetta, A. Peternier, C. Pautasso, W. Binder, S: a Scripting Language for High-Performance RESTful Web Services, Proc. of the 17th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP 2012), New Orleans, LA, USA, February 2012
More information available at http://sosoa.inf.unisi.ch/s
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