SemiSpace
An introduction
What is?
SemiSpace is a light weight
Open Source interpretation of
Tuple Space / Object Space
Use correct tools (1/2)
- Technology is not interchangeable: A tuple space is neither a database nor a grid
- RDBMS
Data only: Long lived relational data. Product: PostgreSQL
Example: Customer information
- Grid
Data and task in same package. Product: GridGain
Example: SETI@home
- Map-reduce
Task is pushed down onto distributed data. Product: Hadoop
Example: Yahoo and Google
Use correct tools (2/2)
- Have the correct expectations
- Is data bound by network traffic?
-
Embarrassingly parallel problems vs Amdahls law
(Where N is number of processors, P is percentage which can be parallelized.)
- Distribution may not always be the solution
- Dedicated servers for single tasks vs all servers perform all tasks
Consequences
Suited for
- propagation of short lived states
- distributed master / worker (or actor) pattern
- distribution (to some extent)
- time boxed queries
- alleviate or predict load (Avoid spiraling death)
- proxying data from within internal net
- mutexing access to task or resource
- Failover and load balancing
Working with
SemiLease write (Object obj, long lifeTimeInMs );
Object read (Object template, long timeout);
Object readIfExists (Object template);
Object take (Object template, long timeout);
Object takeIfExists (Object template);
SemiEventRegistration notify
(Object template,
SemiEventListener listener,
long duration);
Working with
Working with
Working with
Working with
Working with
Working with
Working with
Working with
Working with
Reasons - SemiSpace (1/2)
- Low weight
- Main package depends only on XStream and slf4j
- Does not need installation of a server
- Does not use Entry interface
- Supports getters and setters
- Supports arbitrarily large object graphs
- Easily accessible with Maven2
- Open Source (Apache2 license)
- Eclectic: Mix and match
Reasons - SemiSpace (2/2)
- Examples of webservices exposure and J2EE-integration are available
- Terracotta configuration is done once and for all
- Works exactly the same way in single VM as when being distributed
- Presumably simple to port
- Exposes statistics over JMX (if set up with spring config)
- Can use a JDBC back end for long time persistence
- Supplied Actor pattern implementation
CometD
CometD
...and the real time web
In the beginning...
- ...there was HTML
- HTML - HyperText Markup Language
- document-centric
- high latency due to full page loads only
- coarse-grained interactions with the server
- multi-user from the beginning
Classic web model
Next came...
- AJAX - Asynchronous JavaScript And XML
- allowed fine-grained interactions from browser to server
- reduced latency for a lot of client-initiated interactions
- no need for full page load every time
- only pull data for and refresh the parts of the page that required update
- does not provide for server-initiated interactions
Ajax web model
Comet
- Ajax Push technology pattern
- allows full bidirectional, asynchronous communication between browser and server
- Term coined by Alex Russell of the Dojo toolkit
- rekindles hopes of "server push"...
Comet web model
Integration
SemiSpace + Comet
Distributed JSON
Goals
- Implement responsive user interactions for web clients
- Stable API bindings for JavaScript (on the client) and Java
- Generic JSON support
- Easy distribution of JSON objects among clients
- JavaScript to JAVA and vise versa conversion
- Bindings for the Dojo toolkit and for the jQuery toolkit.
- Standalone application
Connection object
var comet = new semispace.Comet(cometImpl, server);
comet.addMetaListener(function(status, message){
// server messages and server status
});
SemiSpace object
var space = new semispace.SemiSpace(connectionObject);
space.notify(template, listener, duration, callback);
space.write(obj, lifeTimeInMs, callback);
space.read(template, timeout, callback);
space.readIfExists(template, callback);
space.take(template, timeout, callback);
space.takeIfExists(template, callback);
Generic JSON
Object:
{"video" : {
"userid" : "128746311",
"orgfile" : "holliday.avi",
"path" : "/data/001/"
}}
Templat:
{"video" : {
"userid" : "128746311"
}}
JavaScript to Java
{
"org_someproject_converter_video" : {
"userid" : "128746311",
"orgfile" : "holliday.avi",
"path" : "/data/001/"
}
}
High scalability
- Jetty & Bayeux
- 1000 Bayeux clients with less than 10 concurrently active threads:
- 1000 long poll requests / 20 s = 50 requests/s
- 50 requests/s * 100 ms/request = 5 concurrent requests
- 5 concurrent requests at any given time => 5 threads active
- Apache httpd would need 1000 threads
Next step
- Apply solid security model
- CometD 2.0 and HTML5 WebSockets support