+ All Categories
Home > Internet > Cloud-Ready Web Messaging With CometD by S. Bordet

Cloud-Ready Web Messaging With CometD by S. Bordet

Date post: 31-May-2015
Category:
Upload: corley-srl
View: 869 times
Download: 0 times
Share this document with a friend
Description:
Slides by the speech of S. Bordet at Cloud Conference 2014
Popular Tags:
35
Simone Bordet [email protected] Cloud-Ready Web Messagging with CometD CloudConf – Torino April 3rd, 2014
Transcript
Page 1: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

Cloud-ReadyWeb Messagging

with CometD

CloudConf – TorinoApril 3rd, 2014

Page 2: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

Who Am I

Simone Bordet [email protected] @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

Page 3: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

Agenda

What is CometD ?

CometD Use Cases

CometD Features

Questions & Answers

Page 4: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

What is CometD ?

Page 5: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 6: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Use Cases

Page 7: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Use Cases

Social Networking Chat and Notifications

Page 8: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Use Cases

Online Gaming Not First Person Shooters – yet :)

Page 9: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Use Cases

Auctions & Trading Updating bids, prices and availability

Page 10: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Use Cases

Systems Monitoring Alerts and System Status

Page 11: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Use Cases

Online Collaboration/Productivity Tools

Page 12: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 13: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Overview

Page 14: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 15: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 16: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 17: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Features

Page 18: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

});

Page 19: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 20: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 21: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 22: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Cloud Features

Page 23: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 24: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 25: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Features – Clustering

Page 26: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 27: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 28: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Features – Seti

B

A C

Client A Client B Client C

Page 29: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 30: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Features – OortObjects

A1, A2

B1

NodeA

C1A C2A

users

A1, A2

B1

NodeB

C1B

users

Page 31: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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)

Page 32: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

CometD Features – OortServices

NodeA

P1

game_service

forward(...)

NodeB

P2

game_service

onForward(...)

onForwardSucceeded(...)

Page 33: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

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

Page 34: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

Questions&

Answers

Page 35: Cloud-Ready Web Messaging  With CometD by S. Bordet

Simone Bordet

[email protected]

References

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

Jetty http://eclipse.org/jetty

Intalio/Webtide https://webtide.com


Recommended