Cloud-Ready Web Messaging With CometD by S. Bordet

Post on 31-May-2015

869 Views

Category:

Internet

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Slides by the speech of S. Bordet at Cloud Conference 2014

Transcript

Simone Bordet

sbordet@intalio.com

Cloud-ReadyWeb Messagging

with CometD

CloudConf – TorinoApril 3rd, 2014

Simone Bordet

sbordet@intalio.com

Who Am I

Simone Bordet sbordet@intalio.com @simonebordet

Open Source Contributor Jetty, CometD, MX4J, Foxtrot, LiveTribe, JBoss, Larex

Lead Architect at Intalio/Webtide Jetty's SPDY, FastCGI and HTTP client maintainer

CometD project leader Web messaging framework

Simone Bordet

sbordet@intalio.com

Agenda

What is CometD ?

CometD Use Cases

CometD Features

Questions & Answers

Simone Bordet

sbordet@intalio.com

What is CometD ?

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

Simone Bordet

sbordet@intalio.com

CometD Use Cases

Simone Bordet

sbordet@intalio.com

CometD Use Cases

Social Networking Chat and Notifications

Simone Bordet

sbordet@intalio.com

CometD Use Cases

Online Gaming Not First Person Shooters – yet :)

Simone Bordet

sbordet@intalio.com

CometD Use Cases

Auctions & Trading Updating bids, prices and availability

Simone Bordet

sbordet@intalio.com

CometD Use Cases

Systems Monitoring Alerts and System Status

Simone Bordet

sbordet@intalio.com

CometD Use Cases

Online Collaboration/Productivity Tools

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

Simone Bordet

sbordet@intalio.com

CometD Overview

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

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

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

Simone Bordet

sbordet@intalio.com

CometD Features

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();

});

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

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

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

Simone Bordet

sbordet@intalio.com

CometD Cloud Features

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

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

Simone Bordet

sbordet@intalio.com

CometD Features – Clustering

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

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

Simone Bordet

sbordet@intalio.com

CometD Features – Seti

B

A C

Client A Client B Client C

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

Simone Bordet

sbordet@intalio.com

CometD Features – OortObjects

A1, A2

B1

NodeA

C1A C2A

users

A1, A2

B1

NodeB

C1B

users

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)

Simone Bordet

sbordet@intalio.com

CometD Features – OortServices

NodeA

P1

game_service

forward(...)

NodeB

P2

game_service

onForward(...)

onForwardSucceeded(...)

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

Simone Bordet

sbordet@intalio.com

Questions&

Answers

Simone Bordet

sbordet@intalio.com

References

CometD http://cometd.org http://docs.cometd.org

Jetty http://eclipse.org/jetty

Intalio/Webtide https://webtide.com

top related