• Save
Comet for highly scalable applications
Upcoming SlideShare
Loading in...5
×
 

Comet for highly scalable applications

on

  • 18,698 views

MIchael Carter and Arthur Lee's talk about Comet (why it's good, how to implement, and some specifics about the Orbited comet server)

MIchael Carter and Arthur Lee's talk about Comet (why it's good, how to implement, and some specifics about the Orbited comet server)

Statistics

Views

Total Views
18,698
Views on SlideShare
16,321
Embed Views
2,377

Actions

Likes
34
Downloads
0
Comments
1

21 Embeds 2,377

http://code-inside.de 1892
http://blog.codeinside.eu 292
http://localhost:3000 61
http://www.slideshare.net 60
http://webapp:3000 14
http://localhost 10
http://192.168.56.102:3000 9
http://translate.googleusercontent.com 9
http://192.168.33.10:3000 7
http://192.168.56.101:3000 6
http://www.cliveboulton.com 3
http://cliveboulton.com 3
http://localhost:8080 2
http://wavm:3000 2
http://192.168.56.1:3000 1
http://static.slidesharecdn.com 1
http://1.localhost.localdomain:3000 1
http://webcache.googleusercontent.com 1
https://s2-eu.ixquick-proxy.com 1
http://www.google.de 1
http://s3.amazonaws.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Do you mind if I pblish this at http://highlyscalable.com/ ?
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Comet for highly scalable applications Comet for highly scalable applications Presentation Transcript

  • Comet for Highly- Scalable Applications Michael Carter and Arthur Lee diagrams by Jacob Rus 24 October 2007 The Ajax Experience Boston
  • What is Comet? “Comet” describes a model of user interaction Pushing real-time updates to web browsers Renkoo Gmail Chat Meebo
  • Old Method: Polling Otherwise known as “hammering the server” App (Event Dispatcher (Event Queues inside) Browsers
  • Old Method: Polling Otherwise known as “hammering the server” App (Event Dispatcher (Event Queues inside) Browsers
  • Old Method: Polling Otherwise known as “hammering the server” App (Event Dispatcher (Event Queues inside) Browsers
  • Old Method: Polling Otherwise known as “hammering the server” App (Event Dispatcher (Event Queues inside) Browsers
  • Old Method: Polling Otherwise known as “hammering the server” App (Event Dispatcher (Event Queues inside) Browsers
  • Old Method: Polling Otherwise known as “hammering the server” App (Event Dispatcher (Event Queues inside) Browsers
  • Polling Overview Old and busted Pros: • Easy to implement • Client side • Server side Cons: • Wasted requests • Additional latency
  • Enter Long-Polling The new hotness Pros: • Latency—gone! • Client side still easy Cons: • Difficult to scale server-side • Conceptually more complicated
  • Vertical Scaling: How do you scale comet on a single server? photo by Michael (mx5tx)
  • Vertical Scaling: How do you scale comet on a single server? Wrong way: Use a threaded server like Apache or IIS Threaded Comet Dispatcher • Supports a few Browsers Event Connect dozen users Queue Queue App • CPU usage and latency go through the roof as users are added
  • Vertical Scaling: How do you scale comet on a single server? Wrong way: Use a threaded server like Apache or IIS Threaded Comet Dispatcher • Supports a few Browsers Event Connect dozen users Queue Queue App • CPU usage and latency go through the roof as users are added
  • Vertical Scaling: How do you scale comet on a single server? Wrong way: Use a threaded server like Apache or IIS Threaded Comet Dispatcher • Supports a few Browsers Event Connect dozen users Queue Queue App • CPU usage and latency go through the roof as users are added
  • Vertical Scaling: How do you scale comet on a single server? Wrong way: Use a threaded server like Apache or IIS Threaded Comet Dispatcher • Supports a few Browsers Event Connect dozen users Queue Queue App • CPU usage and latency go through the roof as users are added
  • Vertical Scaling: How do you scale comet on a single server? Wrong way: Use a threaded server like Apache or IIS Threaded Comet Dispatcher • Supports a few Browsers Event Connect dozen users Queue Queue App • CPU usage and latency go through the roof as users are added
  • Vertical Scaling: How do you scale comet on a single server? Wrong way: Use a threaded server like Apache or IIS Compared to polling: Latency reduced for very light load Avg. latency depends on the order of events As much as 7× the CPU for moderate load CPU-bound at moderate load
  • Vertical Scaling: How do you scale comet on a single server? Right way: Use an event-based architecture • Supports as Event-Based Comet Dispatcher many users as Browsers Event Connect CPU and I/O Queue Pool App can handle • CPU usage scales linearly and latency remains low
  • Vertical Scaling: How do you scale comet on a single server? Right way: Use an event-based architecture • Supports as Event-Based Comet Dispatcher many users as Browsers Event Connect CPU and I/O Queue Pool App can handle • CPU usage scales linearly and latency remains low
  • Vertical Scaling: How do you scale comet on a single server? Right way: Use an event-based architecture • Supports as Event-Based Comet Dispatcher many users as Browsers Event Connect CPU and I/O Queue Pool App can handle • CPU usage scales linearly and latency remains low
  • Vertical Scaling: How do you scale comet on a single server? Right way: Use an event-based architecture Compared to polling: Decreased latency and CPU usage Compared to threaded Comet: Vastly decreased CPU usage Order of events irrelevant Performance degrades gracefully
  • Horizontal Scaling: How do you scale comet across many servers? photo by ulybug
  • Horizontal Scaling: How do you scale comet across many servers? Wrong way: Build the whole software stack into the comet server Embed publish-subscribe architecture into comet server Keep application state within comet nodes Allow comet nodes to communicate with each-other
  • Horizontal Scaling: How do you scale comet across many servers? Wrong way: Build the whole software stack into the comet server • Design is inflexible, can’t Application Node scale for some Comet Nodes uses • Hard to scale to many nodes A B C D E F in the best case Browsers
  • Horizontal Scaling: How do you scale comet across many servers? Wrong way: Build the whole software stack into the comet server • Design is inflexible, can’t Application “A” sends message Node to “E” scale for some Comet Nodes uses • Hard to scale to many nodes A B C D E F in the best case Browsers
  • Horizontal Scaling: How do you scale comet across many servers? Wrong way: Build the whole software stack into the comet server • Design is inflexible, can’t Application “E” sends response Node to “A” scale for some Comet Nodes uses • Hard to scale to many nodes A B C D E F in the best case Browsers
  • Horizontal Scaling: How do you scale comet across many servers? Right way: Share nothing between nodes • No CPU or I/O overhead of sharing state Application Node • Comet CPU usage Nodes scales linearly and latency remains low Browsers
  • Horizontal Scaling: How do you scale comet across many servers? Right way: Use Orbited «wink» Distributed hash table Application Hash Pre-defined Nodes Function Comet hash function Nodes Leave authenti- cation to app layer A B C D E F Browsers
  • Horizontal Scaling: How do you scale comet across many servers? Right way: Use Orbited «wink» Distributed hash table “B” sends Application Hash Pre-defined Nodes message Function to “E” Comet hash function Nodes Leave authenti- cation to app layer A B C D E F Browsers
  • Horizontal Scaling: How do you scale comet across many servers? Right way: Use Orbited «wink» Distributed hash table “E” sends Application Hash Pre-defined Nodes response Function to “B” Comet hash function Nodes Leave authenti- cation to app layer A B C D E F Browsers
  • Publish / Subscribe Pushing published events to groups of browsers What’s it good for? Applications for which multiple users need the same live updates
  • Publish / Subscribe Pushing published events to groups of browsers What’s it good for? Applications for which multiple users need the same live updates real-time chat
  • Publish / Subscribe Pushing published events to groups of browsers What’s it good for? Applications for which multiple users need the same live updates stock tickers real-time chat
  • Scaling Pub/Sub How do you scale publish/subscribe horizontally? If we start with a single comet node, which dispatches events to multiple users in multiple groups then how do we scale up to multiple comet nodes?
  • Scaling Pub/Sub How do you scale publish/subscribe horizontally? If we start with a single node, which dispatches events to multiple users in multiple groups… A single comet Application Node node serves all users and all Comet Dispatcher groups Node Browsers
  • Scaling Pub/Sub How do you scale publish/subscribe horizontally? …then how do we scale up to a pair of nodes? Either we arrange Application Node nodes by group: All of a group’s Comet Dispatcher Nodes events are sent by one node Browsers
  • Scaling Pub/Sub How do you scale publish/subscribe horizontally? …then how do we scale up to a pair of nodes? Or we arrange Application Node nodes by user: A user receives Comet Dispatcher Nodes all events from the same node Browsers
  • Scaling Pub/Sub How do you scale publish/subscribe horizontally? But how, specifically? Split the architecture into layers Do not mix pub/sub layer App Publish/Subscribe Cloud with comet dispatcher Comet Dispatcher Nodes Treat pub/sub layer as a black box Browsers
  • Pub/Sub Options Publish/subscribe already has solutions Don’t reinvent the wheel: Many well-understood, scalable publish/subscribe solutions exist • Internet Relay Chat: Nearly 20 years old. Scales well for large groups of users. • XMPP (Jabber): Flexible protocol. Does presence well, in addition to messaging. • Java Message Service: It’s enterprise, baby.
  • Pub/Sub with Orbited Orbited can be easily added to a pub/sub stack Scaling through modularity: Its simplicity makes Orbited easy to add to any web app architecture Orbited handles Orbited comet dispatch Pub/Sub Stack Internet IRC or Jabber Relay IRC Bridge Chat handles publish/ Orbited subscribe Application / App servers do Web Server Browser everything else
  • Conclusion: • Polling latency unacceptable • Comet solves this problem • Impossible to scale Comet with threaded design • Event-based architecture is necessary • Horizontal scaling requires “share nothing” design • Publish/subscribe is a difficult problem • Scaling pub/sub is easiest with layered architecture
  • Michael Carter CarterMichael@gmail.com http://www.orbited.org/ 24 September 2007 AJAXWorld