Simone Bordet gave a presentation on CometD, a web messaging framework that implements a publish/subscribe pattern for web applications. CometD allows for server push capabilities and is cloud-ready, either being stateless or easily clusterable. Simone discussed several use cases for CometD including social networking, chat, online gaming, auctions/trading, and systems monitoring. Key features of CometD were also summarized, including its JavaScript and server-side libraries, performance, clustering capabilities, and support for cloud environments.
5. Simone Bordet
sbordet@intalio.com
What is CometD
CometD is a web messaging framework
Implements a publish/subscribe pattern on the web
Web applications use a request/response paradigm
Because historically web applications run over HTTP
CometD uses a messaging paradigm
For example: 1 “request” message, 3 “response” messages
Server push – no “request”, 1-N “response” messages
Cloud-ready
Either stateless or easily clusterable
12. Simone Bordet
sbordet@intalio.com
Comet Web Applications
A new kind of web applications
Server-side event driven
Highly dynamic using AJAX / WebSocket on the client
Asynchronous and concurrent by definition
Big impacts on servers
Servers must support async I/O
Thread-per-request model does not scale
Servers must support WebSocket
With an easy fall-back to HTTP
14. Simone Bordet
sbordet@intalio.com
CometD Features
CometD provides libraries
Build your own solutions with the CometD libraries
No out of the box products
CometD JavaScript Libraries
CometD Java Libraries
15. Simone Bordet
sbordet@intalio.com
CometD Performance
CometD Load Test (using a real chat application)
HTTP
20k clients
50k messages/s
200 ms median latency
WebSocket
100k clients
50k messages/s
4 ms median latency
16. Simone Bordet
sbordet@intalio.com
CometD Performance
CometD 3
Roughly 25% to 100% better than CometD 2
Depending on the load
CometD 3 based on Servlet 3.1
Ships new HTTP transport based on Servlet 3.1 Async I/O
Jetty 9.1 implements Servlet 3.1
Implementation already very stable
18. Simone Bordet
sbordet@intalio.com
CometD Features – JavaScript
require(['dojox/cometd', 'dojo/domReady!'],
function(cometd) {
cometd.init('http://myserver/cometd');
cometd.subscribe('/my/channel', function(message) {
var data = message.data;
// Do something with the data
});
cometd.publish('/my/channel', {
chatText: 'hello!'
});
cometd.disconnect();
});
19. Simone Bordet
sbordet@intalio.com
CometD Features – JavaScript
Easy to make Comet “Hello Worlds”
Very difficult to make it fail nicely in real scenarios –
CometD does it
Network disconnection detection
Applications notified via function callback
Message batching
Sending multiple messages to server efficiently
Page reload extension
Reload a page in the browser without losing connectivity
20. Simone Bordet
sbordet@intalio.com
CometD Features – Server
Spring Framework integration
Confidentiality
HTTPS and WSS supported out of the box
Authentication
Controlled via SecurityPolicy
OAuth integration
Authorization
Coarse grained via SecurityPolicy
Fine grained via channel Authorizers
21. Simone Bordet
sbordet@intalio.com
CometD Features – Server
Transport independence (both client and server)
Applications do not hardcode to a specific transport
Lazy messages
Deliver non important messages on first occasion
Save I/O and CPU when it matters
Acknowledge Extension
Provides server-to-client ordering and acknowledgement of
messages
Activity Extension
Disconnect idle clients after a period of inactivity
23. Simone Bordet
sbordet@intalio.com
CometD Cloud Features
The Cloud:
Dynamic horizontal scaling under load
Various degrees of support for fail-over
Almost always requires application support
Applications have to be aware of multiple nodes
Data sharing / replication
24. Simone Bordet
sbordet@intalio.com
CometD Features – Clustering
Oort
CometD's scalability clustering solution
Shards clients among nodes
Not a high availability solution
On node failure clients reconnect automatically
But may have lost information
Oort cluster members autodiscovery
Multicast based
Static based on “well known” nodes
Existing nodes forward topology to new nodes
26. Simone Bordet
sbordet@intalio.com
CometD Features – Oort
Oort cluster messages auto re-broadcasting
For example, chat applications work out of the box
No code needed !
B
A C
Client A Client B Client C
27. Simone Bordet
sbordet@intalio.com
CometD Features – Seti
Seti
Clustered peer-to-peer communication
Oort performs broadcasting communication
Seti maps a user ID token to a session ID
Presence information is broadcasted on the cluster
Each Seti knows the location of all user IDs
Efficient peer-to-peer communication
Multiple session IDs for the same user ID
For example, connecting from desktop and mobile
29. Simone Bordet
sbordet@intalio.com
CometD Features – OortObjects
Distributed OortObjects
Distribution of object state across nodes
OortObject<T>
A composite, uniquely named, object made of “parts”
Only one “part” is owned by the node, others are read-only
Trades more memory for smaller data access latency
Typical Examples
The number of users on each node
The list of chat rooms a friend has joined
The friends of a friend in a social application
31. Simone Bordet
sbordet@intalio.com
CometD Features – OortServices
Distributed OortServices
Forwarding of service actions across nodes
OortService<R, C>
One uniquely named service in each node
Forwards actions to owner node (possibly itself)
Trades less memory for higher data access latencies
Typical Examples
Precise counters (even unique-across-cluster)
Update actions (e.g. chess moves)
33. Simone Bordet
sbordet@intalio.com
CometD Features – OortObjects
OortObject and OortService allow sharding
Geographical-based, load-based, business-based
Typical examples
US users vs EU users
Play games locally for better performance