SlideShare a Scribd company logo
1 of 71
Download to read offline
Real-Time Ruby for the Real-Time Webaka IM for web-applications Ilya Grigorik CTO / PostRank
www.postrank.com www.igvita.com @igrigorik Background:   - PHP, Perl  - Ruby + Rails from ‘06
Real-Time: the hype & the technology Real-Time: the benefits XMPP AMQP PSHB WebHooks Ruby examples Real-life applications Fully buzzword compliant! The slides… Questions & Comments My blog
The Hype! Make it stop!
“Solution Exhibits Under 700 Nanoseconds of Latency for Inter-Process Communication Messaging” (micro/nano) seconds milliseconds 500ms is real-time enough to feel real-time for IM.  seconds Real-time web is IM for web-services minutes / hours Real-Time has many definitions It all depends on your context
+ New Applications + Better Architecture
Many wasteful checks Data? No Data? No Data? Yes Polling: painful, wasteful
Extensible Messaging and Presence Protocol
From: A, To: B Hello! From: A, To: B Hello! Extensible Messaging and Presence Protocol (XMPP)
Event-stream protocol Persistent connections Presence XMPP Features Identity and authentication
User Domain Resource ilya@postrank.com/office Jabber Software Foundation JID: Federation, Identity  & Authentication
<message from="ilya@postrank.com/office" type="chat" to="ilya@igvita.com" id="aae1a"> <body>hello</body> <active xmlns="http://jabber.org/protocol/chatstates"/> </message> Verbose protocol (XML) Example: Message Routing with XMPP
XMPP in the wild: Google Talk
XMPP in the wild: Google Talk + Video
Psi: cross-platform Jabber/XMPP client
require"rubygems" require"xmpp4r" jid=Jabber::JID::new("ilya@postrank.com") client=Jabber::Client.new(jid) client.connect("talk.google.com") client.auth("password") to = "ilya@aiderss.com" subject = "Jabber client" message = "Hello XMPP World!" piclient.sendJabber::Message::new(to, message).set_subject(subject) # <message to='ilya@igvita.com'> #   <body>Hello XMPP World!</body> #   <subject>Jabber client</subject> # </message> XMPP4R (Ruby) Demo
require "rubygems" require "xmpp4r" jid= Jabber::JID::new("ilya@postrank.com") client = Jabber::Client.new(jid) client.connect("talk.google.com") client.auth("password") to = "ilya@postrank.com" subject = "Jabber client" message = "Hello XMPP World!" piclient.sendJabber::Message::new(to, message).set_subject(subject) # <message to='ilya@igvita.com'> #   <body>Hello XMPP World!</body> #   <subject>Jabber client</subject> # </message> XMPP4R (Ruby) Demo
client.send(Jabber::Presence.new.set_type(:away)) #  <presence from='daniel@aiderss.com/iMac8D2CB97D' to='ilya@postrank.com/0EDD826C' xmlns='jabber:client'> #    <show>away</show> #    <priority>0</priority> #    <x xmlns='http://www.apple.com/xmpp/idle'> #      <idle-since>2009-04-01T21:48:15Z</idle-since> #    </x> #  </presence> client.add_message_callbackdo|m|   puts  "#{m.from} -- #{m.body}" end # > daniel@postrank.com  -- Hey! Client Idle… XMPP4R (Ruby) Demo
client.send(Jabber::Presence.new.set_type(:available)) #  <presence from='daniel@aiderss.com/iMac8D2CB97D' to='ilya@aiderss.com/0EDD826C' xmlns='jabber:client'> #    <show>away</show> #    <priority>0</priority> #    <x xmlns='http://www.apple.com/xmpp/idle'> #      <idle-since>2009-04-01T21:48:15Z</idle-since> #    </x> #  </presence> client.add_message_callbackdo|m| puts"#{m.from} -- #{m.body}" end # > daniel@postrank.com  -- Hey! Client Idle… XMPP4R (Ruby) Demo
One-to-many distribution + C2S
XEP-0060: Publish-Subscribe (Pubsub)
Persistent connection Subscribe New message! Publish-Subscribe
<iqtype='set‘ from='hamlet@denmark.lit/blogbot' to='pubsub.shakespeare.lit'id='pub1'> <pubsubxmlns='http://jabber.org/protocol/pubsub'> <publishnode='princely_musings'>       <item>         <entry xmlns='http://www.w3.org/2005/Atom'>           <title>Soliloquy<title>           <summary> To be, or not to be: that is the question!           <summary>           <link rel='alternate' type='text/html' href='http://denmark.lit/2003/12/13/atom03'/>           <id>tag:denmark.lit,2003:entry-32397</id>           <published>2003-12-13T18:30:02Z</published>           <updated>2003-12-13T18:30:02Z</updated>         </entry>       </item> </publish> </pubsub> </iq> IQ Stanza PubSub Protocol: Client XML
<iq type='set‘ from='hamlet@denmark.lit/blogbot' to='pubsub.shakespeare.lit'id='pub1'>   <pubsubxmlns='http://jabber.org/protocol/pubsub'>     <publish node='princely_musings'> <item> <entryxmlns='http://www.w3.org/2005/Atom'> <title>Soliloquy<title> <summary> To be, or not to be: that is the question! <summary> <linkrel='alternate'type='text/html'  href='http://denmark.lit/2003/12/13/atom03'/> <id>tag:denmark.lit,2003:entry-32397</id> <published>2003-12-13T18:30:02Z</published> <updated>2003-12-13T18:30:02Z</updated> </entry> </item>     </publish>   </pubsub> </iq> AtomPub PubSub Protocol: Client XML
Distribute XEP-0060: Publish-Subscribe (Pubsub) Publish
<messagefrom='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'> <eventxmlns='http://jabber.org/protocol/pubsub#event'> <itemsnode='princely_musings'> <itemid='ae890ac52d0df67ed7cfdf51b644e901'> [...ENTRY...] </item> </items> </event> </message> <messagefrom='pubsub.shakespeare.lit' to='bernardo@denmark.lit' id='bar'> <eventxmlns='http://jabber.org/protocol/pubsub#event'> <itemsnode='princely_musings'> <itemid='ae890ac52d0df67ed7cfdf51b644e901'> [...ENTRY...] </item> </items> </event> </message> Subscriber A Subscriber B XEP-0060: Publish-Subscribe (Pubsub)
XMPP XMPP XMPP Real-time communication
require'fire_hydrant' require'yaml' hydrant=FireHydrant.new(YAML.load(File.read("config.yml"))) hydrant.on_location_updatedo|user| puts"#{user.token} has moved to #{user.locations.first}." end hydrant.run! Push notifications Ruby + FireEagle via XMPP
EjabberdErlang Djabberd			Perl OpenFire			Java Tigase			Java Defacto XMPP server RPM, GUI, shiny XMPP / Jabber Servers
Advanced Message Queuing Protocol (AMQP)
“AMQP is an open Internet Protocol for Business Messaging” AMQP Working Group (16 companies)
Consumer AMQP Broker AMQP Architecture Publisher
Broker Clustering AMQP Clustering
Routing key:usd.stock.amzMessage: I like AMZ! Direct Exchange Topic Exchange Fanout Exchange AMQP Broker Internals
Routing key:usd.stock.amzMessage: I like AMZ! Direct Exchange Topic Exchange Fanout Exchange Queue Name: amazonBind:usd.stock.amz AMQP Direct Exchange
Routing key:usd.stock.amzMessage: I like AMZ! Direct Exchange Topic Exchange Fanout Exchange Queue Name: stocksBind:usd.stock.* AMQP Topic Exchange
Routing key:usd.stock.msftMessage: I like Microsoft!  Direct Exchange Topic Exchange Fanout Exchange Queue  Message: I like Microsoft!  AMQP Topic Exchange
Routing key:usd.stock.msftMessage: I like Microsoft! Direct Exchange Topic Exchange Fanout Exchange Queue 2 Name: stocksBind:“” Queue 1 AMQP Fanout Exchange
Routing key: usd.stock.msftMessage: I like Microsoft!  Direct Exchange Topic Exchange Fanout Exchange Queue 2 Message: I like Microsoft Queue 1 AMQP Fanout Exchange
AMQP Kung-fu: Load-balancing
Routing key:usd.stock.amzMessage: I like AMZ!  Direct Exchange Topic Exchange Fanout Exchange Only one client gets the message! Queue AMQP Load Balancing
Bind:purchase.pdf GET/purchase OK Elastic AMQP Load-balancing
More AMQP Kung-fu:   - Pubsub   - Key routing   - Failover   - Instant feedback   - At least once, exactly-once   - … http://bit.ly/igvita-amqp
require'mq' AMQP.start(:host=>'amqp-server.com')do mq=MQ.new mq.topic('stocks').publish("5.95",:key=>"usd.amz") end AMQP.start(:host => 'amqp-server.com') do mq= MQ.new mq.queue(’stocks').bind(mq.topic('stocks'), :key => 'usd.*').subscribe{ |price|       print ’stock quote: ', price } end Publisher AMQP + Ruby Example
require 'mq' AMQP.start(:host => 'amqp-server.com') do mq= MQ.new mq.topic('stocks').publish("5.95", :key => "usd.amz") end   AMQP.start(:host=>'amqp-server.com')do mq=MQ.new mq.queue(‘stocks').bind(mq.topic('stocks'),:key=>'usd.*').subscribe{|price| print‘stock quote: ',price } end Consumer AMQP + Ruby Example
http://blog.webhooks.org/2009/04/23/slides-from-pivotal-labs-talk/ WebHooks: Pattern for enabling user-defined callbacks in web-applications
http://blog.webhooks.org/2009/04/23/slides-from-pivotal-labs-talk/ WebHooks @ PayPal
http://blog.webhooks.org/2009/04/23/slides-from-pivotal-labs-talk/ /register  http://callback-1.com /register  http://callback-2.com 1 ok http://blog.webhooks.org/2009/04/23/slides-from-pivotal-labs-talk/ /post  Hello World! 2 ok /post  Hello World! http://callback-1.com 3 http://callback-2.com WebHooks Workflow /post  Hello World!
WebHooks Workflow WebHooks @ GitHub
Rails ActiveRecord  + WebHooks
http://github.com/jcapote/watercoolr -> POST /channels ← { 'id':'2d0128d' } 1 -> POST /subscribers data={     'channel':'2d0128d',      'url':'http://api.calback.com/handler'  } ← { 'status': 'OK' } 2 you -> POST /messages data={ 'channel':'2d0128d', 'message':'hey guys!' } watercoolr -> POSThttp://api.callback.com/handler data='hey guys!'    ...for every subscriber... ← { 'status': 'OK' } 3 Watercoolr: Ruby WebHooks Server via a simple Sinatra app
require'rubygems' require'rest_client' require'json' # ruby postbin.rb http://www.postbin.org/1j11vyp puts "creating channel..." resp=RestClient.post'http://watercoolr.appspot.com/channels', :data => '' id =JSON.parse(resp)["id"] puts "adding subscriber to channel #{id}" resp = RestClient.post 'http://watercoolr.appspot.com/subscribers',                  :data => { :channel => id, :url => ARGV[0] }.to_json puts resp # {"status":"OK"} puts "posting message to #{id}" resp = RestClient.post 'http://watercoolr.appspot.com/messages',                  :data => { :channel => id, :message => 'Hello World' }.to_json puts resp # {"status":"OK"} Watercoolr on Google App Engine DataMapper + Sinatra + Jruby
require'rubygems' require'rest_client' require'json' # ruby postbin.rb http://www.postbin.org/1j11vyp puts "creating channel..." resp = RestClient.post 'http://watercoolr.appspot.com/channels', :data => '' id = JSON.parse(resp)["id"] puts "adding subscriber to channel #{id}" resp=RestClient.post'http://watercoolr.appspot.com/subscribers',  :data => { :channel => id, :url => ARGV[0] }.to_json puts resp# {"status":"OK"} puts "posting message to #{id}" resp = RestClient.post 'http://watercoolr.appspot.com/messages',                  :data => { :channel => id, :message => 'Hello World' }.to_json puts resp # {"status":"OK"} Watercoolr on Google App Engine DataMapper + Sinatra + Jruby
require'rubygems' require'rest_client' require'json' # ruby postbin.rb http://www.postbin.org/1j11vyp puts "creating channel..." resp = RestClient.post 'http://watercoolr.appspot.com/channels', :data => '' id = JSON.parse(resp)["id"] puts "adding subscriber to channel #{id}" resp = RestClient.post 'http://watercoolr.appspot.com/subscribers',                  :data => { :channel => id, :url => ARGV[0] }.to_json puts resp # {"status":"OK"} puts "posting message to #{id}" resp=RestClient.post'http://watercoolr.appspot.com/messages',  :data => { :channel => id, :message => 'Hello World' }.to_json puts resp# {"status":"OK"} Watercoolr on Google App Engine DataMapper + Sinatra + Jruby
http://bit.ly/igvita-watercoolr http://www.github.com/igrigorik/watercoolr http://www.postbin.org POST’ing to PostBin great debugging tool
PubSub over HTTP basically, WebHooks…
“A simple, open, server-to-server web-hook-based pubsub (publish/subscribe) protocol as an extension to Atom and RSS.” “Parties (servers) speaking the PubSubHubbub protocol can get near-instant notifications (via webhook callbacks) when a topic (feed URL) they're interested in is updated.”  http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.2.html http://docs.google.com/present/view?id=ajd8t6gk4mh2_34dvbpchfs +Spec’edPubSub Protocol +  Deployed & Available +  XML Transport   -  XML Transport -  Not as general purpose -  No firehose
1 2
3 4
PSHB in the Wild Google, Typepad, Wordpress…
require'pubsubhubbub' EventMachine.run {   hub =EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/') # subscribe to real-time notifications hub.subscribe"http://blog.yoursite.com/atom.xml", "http://yourhub.com/hubbub” # unsubscribe  hub.unsubscribe "http://blog.yoursite.com/atom.xml", "http://yourhub.com/hubbub” hub.callback { puts "Processed" } hub.errback  { puts "Error! " + hub.response_header.status.to_s } } Consuming PSHB in Ruby gem install pubsubhubbub
require'pubsubhubbub' EventMachine.run {   hub =EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/') # subscribe to real-time notifications hub.subscribe "http://blog.yoursite.com/atom.xml", "http://yourhub.com/hubbub” # unsubscribe  hub.unsubscribe"http://blog.yoursite.com/atom.xml", "http://yourhub.com/hubbub” hub.callback { puts "Processed" } hub.errback  { puts "Error! " + hub.response_header.status.to_s } } Consuming PSHB in Ruby gem install pubsubhubbub
require'pubsubhubbub' EventMachine.run {   hub =EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/')   # subscribe to real-time notifications hub.subscribe "http://blog.yoursite.com/atom.xml", "http://yourhub.com/hubbub”   # unsubscribe  hub.unsubscribe "http://blog.yoursite.com/atom.xml", "http://yourhub.com/hubbub” hub.callback { puts "Processed" } hub.errback  { puts "Error! "+hub.response_header.status.to_s } } Consuming PSHB in Ruby gem install pubsubhubbub
require'pubsubhubbub' EventMachine.run {   hub =EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/publish') # publish notification to all subscribers hub.publish ['http://www.test.com', 'http://www.test.com/2'] hub.callback { puts "Notified PSHB Hub" } hub.errback  { puts "Notification failed" + hub.response_header.status.to_s }   } Publishing PSHB in Ruby gem install pubsubhubbub
require'pubsubhubbub' EventMachine.run {   hub =EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/publish') # publish notification to all subscribers hub.publish ['http://www.test.com', 'http://www.test.com/2'] hub.callback { puts "Notified PSHB Hub" } hub.errback  { puts "Notification failed"+hub.response_header.status.to_s }   } Publishing PSHB in Ruby gem install pubsubhubbub
http://github.com/igrigorik/pubsubhubbub
Real-Time Web = “IM for web applications” XMPP  :  Presence AMQP :  Routing WebHooks:  Extensibility PubsubHubbub:  PubSub over HTTP
Related Blog Posts: http://bit.ly/igvita-amqp http://bit.ly/igvita-webhooks http://bit.ly/igvita-pshb Questions? The slides… Questions & Comments My blog

More Related Content

What's hot

Don't make me wait! or Building High-Performance Web Applications
Don't make me wait! or Building High-Performance Web ApplicationsDon't make me wait! or Building High-Performance Web Applications
Don't make me wait! or Building High-Performance Web ApplicationsStoyan Stefanov
 
scaling compiled applications - highload 2013
scaling compiled applications - highload 2013scaling compiled applications - highload 2013
scaling compiled applications - highload 2013ice799
 
Building Realtime Apps with Ember.js and WebSockets
Building Realtime Apps with Ember.js and WebSocketsBuilding Realtime Apps with Ember.js and WebSockets
Building Realtime Apps with Ember.js and WebSocketsBen Limmer
 
HTML5 Real-Time and Connectivity
HTML5 Real-Time and ConnectivityHTML5 Real-Time and Connectivity
HTML5 Real-Time and ConnectivityPeter Lubbers
 
Ajax to the Moon
Ajax to the MoonAjax to the Moon
Ajax to the Moondavejohnson
 
Pragmatics of Declarative Ajax
Pragmatics of Declarative AjaxPragmatics of Declarative Ajax
Pragmatics of Declarative Ajaxdavejohnson
 
Xdebug, KCacheGrind and Webgrind with WampServer
Xdebug, KCacheGrind and Webgrind with WampServer  Xdebug, KCacheGrind and Webgrind with WampServer
Xdebug, KCacheGrind and Webgrind with WampServer Mediovski Technology
 
Ajax Tutorial
Ajax TutorialAjax Tutorial
Ajax Tutorialoscon2007
 
Ruby application based on http
Ruby application based on httpRuby application based on http
Ruby application based on httpRichard Huang
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsYan Cui
 
Essential open source tools for serverless developers
Essential open source tools for serverless developersEssential open source tools for serverless developers
Essential open source tools for serverless developersYan Cui
 
The Once And Future Script Loader (v2)
The Once And Future Script Loader (v2)The Once And Future Script Loader (v2)
The Once And Future Script Loader (v2)Kyle Simpson
 
Basics of node.js
Basics of node.jsBasics of node.js
Basics of node.jsYasir Wani
 
Building a Single Page Application using Ember.js ... for fun and profit
Building a Single Page Application using Ember.js ... for fun and profitBuilding a Single Page Application using Ember.js ... for fun and profit
Building a Single Page Application using Ember.js ... for fun and profitBen Limmer
 
Chef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & ChefChef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & Chefice799
 
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love itDrupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love itRyan Weaver
 

What's hot (20)

Don't make me wait! or Building High-Performance Web Applications
Don't make me wait! or Building High-Performance Web ApplicationsDon't make me wait! or Building High-Performance Web Applications
Don't make me wait! or Building High-Performance Web Applications
 
scaling compiled applications - highload 2013
scaling compiled applications - highload 2013scaling compiled applications - highload 2013
scaling compiled applications - highload 2013
 
Building Realtime Apps with Ember.js and WebSockets
Building Realtime Apps with Ember.js and WebSocketsBuilding Realtime Apps with Ember.js and WebSockets
Building Realtime Apps with Ember.js and WebSockets
 
HTML5 Real-Time and Connectivity
HTML5 Real-Time and ConnectivityHTML5 Real-Time and Connectivity
HTML5 Real-Time and Connectivity
 
Ajax to the Moon
Ajax to the MoonAjax to the Moon
Ajax to the Moon
 
Pragmatics of Declarative Ajax
Pragmatics of Declarative AjaxPragmatics of Declarative Ajax
Pragmatics of Declarative Ajax
 
Dust.js
Dust.jsDust.js
Dust.js
 
Xdebug, KCacheGrind and Webgrind with WampServer
Xdebug, KCacheGrind and Webgrind with WampServer  Xdebug, KCacheGrind and Webgrind with WampServer
Xdebug, KCacheGrind and Webgrind with WampServer
 
Making the web faster
Making the web fasterMaking the web faster
Making the web faster
 
What is HTML 5?
What is HTML 5?What is HTML 5?
What is HTML 5?
 
Ajax Tutorial
Ajax TutorialAjax Tutorial
Ajax Tutorial
 
Ruby application based on http
Ruby application based on httpRuby application based on http
Ruby application based on http
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 steps
 
Essential open source tools for serverless developers
Essential open source tools for serverless developersEssential open source tools for serverless developers
Essential open source tools for serverless developers
 
The Once And Future Script Loader (v2)
The Once And Future Script Loader (v2)The Once And Future Script Loader (v2)
The Once And Future Script Loader (v2)
 
Basics of node.js
Basics of node.jsBasics of node.js
Basics of node.js
 
Building a Single Page Application using Ember.js ... for fun and profit
Building a Single Page Application using Ember.js ... for fun and profitBuilding a Single Page Application using Ember.js ... for fun and profit
Building a Single Page Application using Ember.js ... for fun and profit
 
Chef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & ChefChef Conf 2015: Package Management & Chef
Chef Conf 2015: Package Management & Chef
 
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love itDrupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
 
Progressive Enhancement
Progressive EnhancementProgressive Enhancement
Progressive Enhancement
 

Similar to Real-time Ruby for the Real-time Web

Djabot – Python Jabber Bot
Djabot – Python Jabber BotDjabot – Python Jabber Bot
Djabot – Python Jabber Botmarekkuziel
 
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP yucefmerhi
 
Improving Soap Message Serialization
Improving Soap Message SerializationImproving Soap Message Serialization
Improving Soap Message SerializationPrabath Siriwardena
 
An Introduction to Solr
An Introduction to SolrAn Introduction to Solr
An Introduction to Solrtomhill
 
XML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARXML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARStephan Schmidt
 
XMPP, TV and the Semantic Web
XMPP, TV and the Semantic WebXMPP, TV and the Semantic Web
XMPP, TV and the Semantic WebDan Brickley
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With BloggingTakatsugu Shigeta
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Alex Kavanagh
 
Kurzeinführung: Atom Publishing Protocol
Kurzeinführung: Atom Publishing ProtocolKurzeinführung: Atom Publishing Protocol
Kurzeinführung: Atom Publishing ProtocolDirk Haun
 
Comet web applications with Python, Django & Orbited
Comet web applications with Python, Django & OrbitedComet web applications with Python, Django & Orbited
Comet web applications with Python, Django & Orbitedskam
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructureguest517f2f
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructurePamela Fox
 
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]Chris Toohey
 
Internet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAMInternet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAMWoody Pewitt
 
RDFa: The Semantic Web's Missing Link
RDFa: The Semantic Web's Missing LinkRDFa: The Semantic Web's Missing Link
RDFa: The Semantic Web's Missing LinkMark Birbeck
 

Similar to Real-time Ruby for the Real-time Web (20)

Djabot – Python Jabber Bot
Djabot – Python Jabber BotDjabot – Python Jabber Bot
Djabot – Python Jabber Bot
 
Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP Lecture 3 - Comm Lab: Web @ ITP
Lecture 3 - Comm Lab: Web @ ITP
 
Improving Soap Message Serialization
Improving Soap Message SerializationImproving Soap Message Serialization
Improving Soap Message Serialization
 
An Introduction to Solr
An Introduction to SolrAn Introduction to Solr
An Introduction to Solr
 
XML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEARXML and Web Services with PHP5 and PEAR
XML and Web Services with PHP5 and PEAR
 
XMPP, TV and the Semantic Web
XMPP, TV and the Semantic WebXMPP, TV and the Semantic Web
XMPP, TV and the Semantic Web
 
Putting SOAP to REST
Putting SOAP to RESTPutting SOAP to REST
Putting SOAP to REST
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With Blogging
 
Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3Real time web (Orbited) at BCNE3
Real time web (Orbited) at BCNE3
 
XMPP - Beyond IM
XMPP - Beyond IMXMPP - Beyond IM
XMPP - Beyond IM
 
Lecture1 B Frames&Forms
Lecture1 B  Frames&FormsLecture1 B  Frames&Forms
Lecture1 B Frames&Forms
 
Kurzeinführung: Atom Publishing Protocol
Kurzeinführung: Atom Publishing ProtocolKurzeinführung: Atom Publishing Protocol
Kurzeinführung: Atom Publishing Protocol
 
Comet web applications with Python, Django & Orbited
Comet web applications with Python, Django & OrbitedComet web applications with Python, Django & Orbited
Comet web applications with Python, Django & Orbited
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
 
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google InfrastructureLiving in the Cloud: Hosting Data & Apps Using the Google Infrastructure
Living in the Cloud: Hosting Data & Apps Using the Google Infrastructure
 
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
 
Internet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAMInternet protocalls & WCF/DReAM
Internet protocalls & WCF/DReAM
 
RDFa: The Semantic Web's Missing Link
RDFa: The Semantic Web's Missing LinkRDFa: The Semantic Web's Missing Link
RDFa: The Semantic Web's Missing Link
 
Develop webservice in PHP
Develop webservice in PHPDevelop webservice in PHP
Develop webservice in PHP
 
DevDays09 Internet Explorer 8
DevDays09 Internet Explorer 8DevDays09 Internet Explorer 8
DevDays09 Internet Explorer 8
 

More from Ilya Grigorik

Making the web fast(er) - RailsConf 2012
Making the web fast(er) - RailsConf 2012Making the web fast(er) - RailsConf 2012
Making the web fast(er) - RailsConf 2012Ilya Grigorik
 
0-60 with Goliath: High performance web services
0-60 with Goliath: High performance web services0-60 with Goliath: High performance web services
0-60 with Goliath: High performance web servicesIlya Grigorik
 
0-60 with Goliath: Building High Performance Ruby Web-Services
0-60 with Goliath: Building High Performance Ruby Web-Services0-60 with Goliath: Building High Performance Ruby Web-Services
0-60 with Goliath: Building High Performance Ruby Web-ServicesIlya Grigorik
 
Intelligent Ruby + Machine Learning
Intelligent Ruby + Machine LearningIntelligent Ruby + Machine Learning
Intelligent Ruby + Machine LearningIlya Grigorik
 
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
No callbacks, No Threads - Cooperative web servers in Ruby 1.9No callbacks, No Threads - Cooperative web servers in Ruby 1.9
No callbacks, No Threads - Cooperative web servers in Ruby 1.9Ilya Grigorik
 
No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010Ilya Grigorik
 
Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09Ilya Grigorik
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Ilya Grigorik
 
Leveraging Social Media - Strategies & Tactics - PostRank
Leveraging Social Media - Strategies & Tactics - PostRankLeveraging Social Media - Strategies & Tactics - PostRank
Leveraging Social Media - Strategies & Tactics - PostRankIlya Grigorik
 
Ruby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and MonitoringRuby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and MonitoringIlya Grigorik
 
Building Mini Google in Ruby
Building Mini Google in RubyBuilding Mini Google in Ruby
Building Mini Google in RubyIlya Grigorik
 
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comRuby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comIlya Grigorik
 
Event Driven Architecture - MeshU - Ilya Grigorik
Event Driven Architecture - MeshU - Ilya GrigorikEvent Driven Architecture - MeshU - Ilya Grigorik
Event Driven Architecture - MeshU - Ilya GrigorikIlya Grigorik
 
Taming The RSS Beast
Taming The  RSS  BeastTaming The  RSS  Beast
Taming The RSS BeastIlya Grigorik
 

More from Ilya Grigorik (14)

Making the web fast(er) - RailsConf 2012
Making the web fast(er) - RailsConf 2012Making the web fast(er) - RailsConf 2012
Making the web fast(er) - RailsConf 2012
 
0-60 with Goliath: High performance web services
0-60 with Goliath: High performance web services0-60 with Goliath: High performance web services
0-60 with Goliath: High performance web services
 
0-60 with Goliath: Building High Performance Ruby Web-Services
0-60 with Goliath: Building High Performance Ruby Web-Services0-60 with Goliath: Building High Performance Ruby Web-Services
0-60 with Goliath: Building High Performance Ruby Web-Services
 
Intelligent Ruby + Machine Learning
Intelligent Ruby + Machine LearningIntelligent Ruby + Machine Learning
Intelligent Ruby + Machine Learning
 
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
No callbacks, No Threads - Cooperative web servers in Ruby 1.9No callbacks, No Threads - Cooperative web servers in Ruby 1.9
No callbacks, No Threads - Cooperative web servers in Ruby 1.9
 
No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010
 
Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09
 
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
Lean & Mean Tokyo Cabinet Recipes (with Lua) - FutureRuby '09
 
Leveraging Social Media - Strategies & Tactics - PostRank
Leveraging Social Media - Strategies & Tactics - PostRankLeveraging Social Media - Strategies & Tactics - PostRank
Leveraging Social Media - Strategies & Tactics - PostRank
 
Ruby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and MonitoringRuby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and Monitoring
 
Building Mini Google in Ruby
Building Mini Google in RubyBuilding Mini Google in Ruby
Building Mini Google in Ruby
 
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comRuby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
 
Event Driven Architecture - MeshU - Ilya Grigorik
Event Driven Architecture - MeshU - Ilya GrigorikEvent Driven Architecture - MeshU - Ilya Grigorik
Event Driven Architecture - MeshU - Ilya Grigorik
 
Taming The RSS Beast
Taming The  RSS  BeastTaming The  RSS  Beast
Taming The RSS Beast
 

Recently uploaded

Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 

Recently uploaded (20)

Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 

Real-time Ruby for the Real-time Web

  • 1. Real-Time Ruby for the Real-Time Webaka IM for web-applications Ilya Grigorik CTO / PostRank
  • 2. www.postrank.com www.igvita.com @igrigorik Background: - PHP, Perl - Ruby + Rails from ‘06
  • 3. Real-Time: the hype & the technology Real-Time: the benefits XMPP AMQP PSHB WebHooks Ruby examples Real-life applications Fully buzzword compliant! The slides… Questions & Comments My blog
  • 4. The Hype! Make it stop!
  • 5. “Solution Exhibits Under 700 Nanoseconds of Latency for Inter-Process Communication Messaging” (micro/nano) seconds milliseconds 500ms is real-time enough to feel real-time for IM. seconds Real-time web is IM for web-services minutes / hours Real-Time has many definitions It all depends on your context
  • 6. + New Applications + Better Architecture
  • 7. Many wasteful checks Data? No Data? No Data? Yes Polling: painful, wasteful
  • 8.
  • 9. Extensible Messaging and Presence Protocol
  • 10. From: A, To: B Hello! From: A, To: B Hello! Extensible Messaging and Presence Protocol (XMPP)
  • 11. Event-stream protocol Persistent connections Presence XMPP Features Identity and authentication
  • 12. User Domain Resource ilya@postrank.com/office Jabber Software Foundation JID: Federation, Identity & Authentication
  • 13. <message from="ilya@postrank.com/office" type="chat" to="ilya@igvita.com" id="aae1a"> <body>hello</body> <active xmlns="http://jabber.org/protocol/chatstates"/> </message> Verbose protocol (XML) Example: Message Routing with XMPP
  • 14. XMPP in the wild: Google Talk
  • 15. XMPP in the wild: Google Talk + Video
  • 17. require"rubygems" require"xmpp4r" jid=Jabber::JID::new("ilya@postrank.com") client=Jabber::Client.new(jid) client.connect("talk.google.com") client.auth("password") to = "ilya@aiderss.com" subject = "Jabber client" message = "Hello XMPP World!" piclient.sendJabber::Message::new(to, message).set_subject(subject) # <message to='ilya@igvita.com'> # <body>Hello XMPP World!</body> # <subject>Jabber client</subject> # </message> XMPP4R (Ruby) Demo
  • 18. require "rubygems" require "xmpp4r" jid= Jabber::JID::new("ilya@postrank.com") client = Jabber::Client.new(jid) client.connect("talk.google.com") client.auth("password") to = "ilya@postrank.com" subject = "Jabber client" message = "Hello XMPP World!" piclient.sendJabber::Message::new(to, message).set_subject(subject) # <message to='ilya@igvita.com'> # <body>Hello XMPP World!</body> # <subject>Jabber client</subject> # </message> XMPP4R (Ruby) Demo
  • 19. client.send(Jabber::Presence.new.set_type(:away)) # <presence from='daniel@aiderss.com/iMac8D2CB97D' to='ilya@postrank.com/0EDD826C' xmlns='jabber:client'> # <show>away</show> # <priority>0</priority> # <x xmlns='http://www.apple.com/xmpp/idle'> # <idle-since>2009-04-01T21:48:15Z</idle-since> # </x> # </presence> client.add_message_callbackdo|m| puts "#{m.from} -- #{m.body}" end # > daniel@postrank.com -- Hey! Client Idle… XMPP4R (Ruby) Demo
  • 20. client.send(Jabber::Presence.new.set_type(:available)) # <presence from='daniel@aiderss.com/iMac8D2CB97D' to='ilya@aiderss.com/0EDD826C' xmlns='jabber:client'> # <show>away</show> # <priority>0</priority> # <x xmlns='http://www.apple.com/xmpp/idle'> # <idle-since>2009-04-01T21:48:15Z</idle-since> # </x> # </presence> client.add_message_callbackdo|m| puts"#{m.from} -- #{m.body}" end # > daniel@postrank.com -- Hey! Client Idle… XMPP4R (Ruby) Demo
  • 23. Persistent connection Subscribe New message! Publish-Subscribe
  • 24. <iqtype='set‘ from='hamlet@denmark.lit/blogbot' to='pubsub.shakespeare.lit'id='pub1'> <pubsubxmlns='http://jabber.org/protocol/pubsub'> <publishnode='princely_musings'> <item> <entry xmlns='http://www.w3.org/2005/Atom'> <title>Soliloquy<title> <summary> To be, or not to be: that is the question! <summary> <link rel='alternate' type='text/html' href='http://denmark.lit/2003/12/13/atom03'/> <id>tag:denmark.lit,2003:entry-32397</id> <published>2003-12-13T18:30:02Z</published> <updated>2003-12-13T18:30:02Z</updated> </entry> </item> </publish> </pubsub> </iq> IQ Stanza PubSub Protocol: Client XML
  • 25. <iq type='set‘ from='hamlet@denmark.lit/blogbot' to='pubsub.shakespeare.lit'id='pub1'> <pubsubxmlns='http://jabber.org/protocol/pubsub'> <publish node='princely_musings'> <item> <entryxmlns='http://www.w3.org/2005/Atom'> <title>Soliloquy<title> <summary> To be, or not to be: that is the question! <summary> <linkrel='alternate'type='text/html' href='http://denmark.lit/2003/12/13/atom03'/> <id>tag:denmark.lit,2003:entry-32397</id> <published>2003-12-13T18:30:02Z</published> <updated>2003-12-13T18:30:02Z</updated> </entry> </item> </publish> </pubsub> </iq> AtomPub PubSub Protocol: Client XML
  • 27. <messagefrom='pubsub.shakespeare.lit' to='francisco@denmark.lit' id='foo'> <eventxmlns='http://jabber.org/protocol/pubsub#event'> <itemsnode='princely_musings'> <itemid='ae890ac52d0df67ed7cfdf51b644e901'> [...ENTRY...] </item> </items> </event> </message> <messagefrom='pubsub.shakespeare.lit' to='bernardo@denmark.lit' id='bar'> <eventxmlns='http://jabber.org/protocol/pubsub#event'> <itemsnode='princely_musings'> <itemid='ae890ac52d0df67ed7cfdf51b644e901'> [...ENTRY...] </item> </items> </event> </message> Subscriber A Subscriber B XEP-0060: Publish-Subscribe (Pubsub)
  • 28. XMPP XMPP XMPP Real-time communication
  • 29.
  • 30. require'fire_hydrant' require'yaml' hydrant=FireHydrant.new(YAML.load(File.read("config.yml"))) hydrant.on_location_updatedo|user| puts"#{user.token} has moved to #{user.locations.first}." end hydrant.run! Push notifications Ruby + FireEagle via XMPP
  • 31. EjabberdErlang Djabberd Perl OpenFire Java Tigase Java Defacto XMPP server RPM, GUI, shiny XMPP / Jabber Servers
  • 32. Advanced Message Queuing Protocol (AMQP)
  • 33. “AMQP is an open Internet Protocol for Business Messaging” AMQP Working Group (16 companies)
  • 34. Consumer AMQP Broker AMQP Architecture Publisher
  • 36. Routing key:usd.stock.amzMessage: I like AMZ! Direct Exchange Topic Exchange Fanout Exchange AMQP Broker Internals
  • 37. Routing key:usd.stock.amzMessage: I like AMZ! Direct Exchange Topic Exchange Fanout Exchange Queue Name: amazonBind:usd.stock.amz AMQP Direct Exchange
  • 38. Routing key:usd.stock.amzMessage: I like AMZ! Direct Exchange Topic Exchange Fanout Exchange Queue Name: stocksBind:usd.stock.* AMQP Topic Exchange
  • 39. Routing key:usd.stock.msftMessage: I like Microsoft! Direct Exchange Topic Exchange Fanout Exchange Queue Message: I like Microsoft! AMQP Topic Exchange
  • 40. Routing key:usd.stock.msftMessage: I like Microsoft! Direct Exchange Topic Exchange Fanout Exchange Queue 2 Name: stocksBind:“” Queue 1 AMQP Fanout Exchange
  • 41. Routing key: usd.stock.msftMessage: I like Microsoft! Direct Exchange Topic Exchange Fanout Exchange Queue 2 Message: I like Microsoft Queue 1 AMQP Fanout Exchange
  • 43. Routing key:usd.stock.amzMessage: I like AMZ! Direct Exchange Topic Exchange Fanout Exchange Only one client gets the message! Queue AMQP Load Balancing
  • 44. Bind:purchase.pdf GET/purchase OK Elastic AMQP Load-balancing
  • 45. More AMQP Kung-fu: - Pubsub - Key routing - Failover - Instant feedback - At least once, exactly-once - … http://bit.ly/igvita-amqp
  • 46. require'mq' AMQP.start(:host=>'amqp-server.com')do mq=MQ.new mq.topic('stocks').publish("5.95",:key=>"usd.amz") end AMQP.start(:host => 'amqp-server.com') do mq= MQ.new mq.queue(’stocks').bind(mq.topic('stocks'), :key => 'usd.*').subscribe{ |price| print ’stock quote: ', price } end Publisher AMQP + Ruby Example
  • 47. require 'mq' AMQP.start(:host => 'amqp-server.com') do mq= MQ.new mq.topic('stocks').publish("5.95", :key => "usd.amz") end AMQP.start(:host=>'amqp-server.com')do mq=MQ.new mq.queue(‘stocks').bind(mq.topic('stocks'),:key=>'usd.*').subscribe{|price| print‘stock quote: ',price } end Consumer AMQP + Ruby Example
  • 48.
  • 49. http://blog.webhooks.org/2009/04/23/slides-from-pivotal-labs-talk/ WebHooks: Pattern for enabling user-defined callbacks in web-applications
  • 51. http://blog.webhooks.org/2009/04/23/slides-from-pivotal-labs-talk/ /register http://callback-1.com /register http://callback-2.com 1 ok http://blog.webhooks.org/2009/04/23/slides-from-pivotal-labs-talk/ /post Hello World! 2 ok /post Hello World! http://callback-1.com 3 http://callback-2.com WebHooks Workflow /post Hello World!
  • 53. Rails ActiveRecord + WebHooks
  • 54. http://github.com/jcapote/watercoolr -> POST /channels ← { 'id':'2d0128d' } 1 -> POST /subscribers data={ 'channel':'2d0128d', 'url':'http://api.calback.com/handler' } ← { 'status': 'OK' } 2 you -> POST /messages data={ 'channel':'2d0128d', 'message':'hey guys!' } watercoolr -> POSThttp://api.callback.com/handler data='hey guys!' ...for every subscriber... ← { 'status': 'OK' } 3 Watercoolr: Ruby WebHooks Server via a simple Sinatra app
  • 55. require'rubygems' require'rest_client' require'json' # ruby postbin.rb http://www.postbin.org/1j11vyp puts "creating channel..." resp=RestClient.post'http://watercoolr.appspot.com/channels', :data => '' id =JSON.parse(resp)["id"] puts "adding subscriber to channel #{id}" resp = RestClient.post 'http://watercoolr.appspot.com/subscribers', :data => { :channel => id, :url => ARGV[0] }.to_json puts resp # {"status":"OK"} puts "posting message to #{id}" resp = RestClient.post 'http://watercoolr.appspot.com/messages', :data => { :channel => id, :message => 'Hello World' }.to_json puts resp # {"status":"OK"} Watercoolr on Google App Engine DataMapper + Sinatra + Jruby
  • 56. require'rubygems' require'rest_client' require'json' # ruby postbin.rb http://www.postbin.org/1j11vyp puts "creating channel..." resp = RestClient.post 'http://watercoolr.appspot.com/channels', :data => '' id = JSON.parse(resp)["id"] puts "adding subscriber to channel #{id}" resp=RestClient.post'http://watercoolr.appspot.com/subscribers', :data => { :channel => id, :url => ARGV[0] }.to_json puts resp# {"status":"OK"} puts "posting message to #{id}" resp = RestClient.post 'http://watercoolr.appspot.com/messages', :data => { :channel => id, :message => 'Hello World' }.to_json puts resp # {"status":"OK"} Watercoolr on Google App Engine DataMapper + Sinatra + Jruby
  • 57. require'rubygems' require'rest_client' require'json' # ruby postbin.rb http://www.postbin.org/1j11vyp puts "creating channel..." resp = RestClient.post 'http://watercoolr.appspot.com/channels', :data => '' id = JSON.parse(resp)["id"] puts "adding subscriber to channel #{id}" resp = RestClient.post 'http://watercoolr.appspot.com/subscribers', :data => { :channel => id, :url => ARGV[0] }.to_json puts resp # {"status":"OK"} puts "posting message to #{id}" resp=RestClient.post'http://watercoolr.appspot.com/messages', :data => { :channel => id, :message => 'Hello World' }.to_json puts resp# {"status":"OK"} Watercoolr on Google App Engine DataMapper + Sinatra + Jruby
  • 59. PubSub over HTTP basically, WebHooks…
  • 60. “A simple, open, server-to-server web-hook-based pubsub (publish/subscribe) protocol as an extension to Atom and RSS.” “Parties (servers) speaking the PubSubHubbub protocol can get near-instant notifications (via webhook callbacks) when a topic (feed URL) they're interested in is updated.” http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.2.html http://docs.google.com/present/view?id=ajd8t6gk4mh2_34dvbpchfs +Spec’edPubSub Protocol + Deployed & Available + XML Transport - XML Transport - Not as general purpose - No firehose
  • 61. 1 2
  • 62. 3 4
  • 63. PSHB in the Wild Google, Typepad, Wordpress…
  • 64. require'pubsubhubbub' EventMachine.run { hub =EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/') # subscribe to real-time notifications hub.subscribe"http://blog.yoursite.com/atom.xml", "http://yourhub.com/hubbub” # unsubscribe hub.unsubscribe "http://blog.yoursite.com/atom.xml", "http://yourhub.com/hubbub” hub.callback { puts "Processed" } hub.errback { puts "Error! " + hub.response_header.status.to_s } } Consuming PSHB in Ruby gem install pubsubhubbub
  • 65. require'pubsubhubbub' EventMachine.run { hub =EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/') # subscribe to real-time notifications hub.subscribe "http://blog.yoursite.com/atom.xml", "http://yourhub.com/hubbub” # unsubscribe hub.unsubscribe"http://blog.yoursite.com/atom.xml", "http://yourhub.com/hubbub” hub.callback { puts "Processed" } hub.errback { puts "Error! " + hub.response_header.status.to_s } } Consuming PSHB in Ruby gem install pubsubhubbub
  • 66. require'pubsubhubbub' EventMachine.run { hub =EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/') # subscribe to real-time notifications hub.subscribe "http://blog.yoursite.com/atom.xml", "http://yourhub.com/hubbub” # unsubscribe hub.unsubscribe "http://blog.yoursite.com/atom.xml", "http://yourhub.com/hubbub” hub.callback { puts "Processed" } hub.errback { puts "Error! "+hub.response_header.status.to_s } } Consuming PSHB in Ruby gem install pubsubhubbub
  • 67. require'pubsubhubbub' EventMachine.run { hub =EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/publish') # publish notification to all subscribers hub.publish ['http://www.test.com', 'http://www.test.com/2'] hub.callback { puts "Notified PSHB Hub" } hub.errback { puts "Notification failed" + hub.response_header.status.to_s } } Publishing PSHB in Ruby gem install pubsubhubbub
  • 68. require'pubsubhubbub' EventMachine.run { hub =EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/publish') # publish notification to all subscribers hub.publish ['http://www.test.com', 'http://www.test.com/2'] hub.callback { puts "Notified PSHB Hub" } hub.errback { puts "Notification failed"+hub.response_header.status.to_s } } Publishing PSHB in Ruby gem install pubsubhubbub
  • 70. Real-Time Web = “IM for web applications” XMPP : Presence AMQP : Routing WebHooks: Extensibility PubsubHubbub: PubSub over HTTP
  • 71. Related Blog Posts: http://bit.ly/igvita-amqp http://bit.ly/igvita-webhooks http://bit.ly/igvita-pshb Questions? The slides… Questions & Comments My blog

Editor's Notes

  1. ResourceFederationClient to Server <> Server to ServerJabber.orgis the original IM service based on XMPP, the open standard for instant messaging. The service is run by a small group of volunteers. For that reason, you’ll often find people using Jabber and XMPP as synonyms. For all intents and purposes though, they are exactly the same. Having said that, each XMPP user has a “JID” or “Jabber ID”, which captures the following components: user, domain and resource.If you discard the resource component for a second, you’re left with an email address! Hence, as you may guess, the user identification and authentication will be done by a jabber server running on aiderss.com. And then the resource component simply assigns a unique handle, or location for that user. Unlike SMTP, which is stateless, we can have multiple clients be connected to our jabber server, which means we need a unique ID for each one.
  2. XMPP is also not limited to routing text snippets. Recently, Google integrated video chat into their products, once again, using XMPP. You can use XMPP to transfer binary files, real-time video, or anything else that your heart desires (not that it’s a necessarily good idea to do that though).
  3. Fire eagle exposes an XMPP endpoint which anyone can consume to receive your location updates. This saves them a lot of bandwidth and server resources, since the clients don’t have to poll for updates!
  4. Another interesting and fairly popular use for XMPP is the dynamic scalability. Instead of trying to build your own glue to detect and register new servers in the cloud, you could use XMPP and presence to solve this for you: whenever a server comes online, it logs into the XMPP server announcing it’s presence as available. Under load? Set it to “do not disturb”. If the server falls off the network, the XMPP server will detect that and remove it from its roster.