Your SlideShare is downloading. ×
Fast, Scalable
Front/Back-end Services
  using Ruby, Rails and
         XMPP
    Pradeep Elankumaran
      pradeep@intride...
What is XMPP?
•   eXtensible Messaging and Presence Protocol

•   Message-oriented middleware

•   XML-based

•   Various ...
The GOOD
• Open
• Standardized by the IETF
• Decentralized
• Mature
• Customizable
• FAST!
The BAD
• XML is very verbose
• Documentation is not outlined properly
    •   though there are efforts to make this bette...
A Simple XMPP Stanza
                      JID         resource


 <message from=’pradeep@xmpp.org/adium’
     to=’zana@xm...
Some XMPP Features
• Presence
• Instant Messaging
• Publish/Subscribe
• Multi-User Chat
• Federation
• Personal Eventing, ...
The Future
Publish/Subscribe
         <iq type=’set’ to=’pubsub.xmpp.org’
         from=’me@xmpp.org’>
            <pubsub xmlns=’htt...
Publish / Subscribe
• Federated Microblogging using the Personal
  Eventing Protocol (PEP)
• Real-time search
• Real-time ...
Real-time User Interfaces
• BOSH
• Robust, lively interfaces for daily use
• Javascript-based XMPP clients
• Handlers atta...
The Backend
XMPP4R
•gem install ln-xmpp4r
• very full-featured
• threaded, event-based
• BAD: a lack of documentation, steep
  learnin...
strophe-ruby
• gem install yong-stropheruby
• based off libstrophe, a C library
• event-based
• can be run within a Rails ...
The Front-End
BOSH
•   Bi-directional streams Over Synchronous HTTP

•   This is not COMET, which requires a single
    persistent conne...
BOSH
client   <body/>, session


                      BOSH
                    connection   no <body/>
                  ...
Strophe
• Excellent Javascript BOSH client
• written by Jack Moffit (metajack.im)
• written for Chesspark
• used in product...
Strophe
connection = new Strophe.Connection(“/http-bind”);
connection.connect(“pradeep@xmpp.org”, “password”,
           o...
An Example
Present.ly (before)
    Client

             jQuery, polling



     Rails                      Custom Index




         ...
we needed
something better
Present.ly (now)
                                  BOS
                                       H, st
             Client   ...
scales beautifully
demo time
XMPP Servers
• eJabberd
   • written in Erlang, highly scalable, actively maintained
   • runs in production on Present.ly...
Questions?
 pradeep@intridea.com
  twitter: @pradeep24
  http://www.skyfallsin.com
Fast & Scalable Front/Back-ends using Ruby, Rails & XMPP
Upcoming SlideShare
Loading in...5
×

Fast & Scalable Front/Back-ends using Ruby, Rails & XMPP

5,927

Published on

First given at LARubyConf 2009

Published in: Technology

Transcript of "Fast & Scalable Front/Back-ends using Ruby, Rails & XMPP"

  1. 1. Fast, Scalable Front/Back-end Services using Ruby, Rails and XMPP Pradeep Elankumaran pradeep@intridea.com twitter: @pradeep24
  2. 2. What is XMPP? • eXtensible Messaging and Presence Protocol • Message-oriented middleware • XML-based • Various XMPP servers (eJabberd, Openfire, Tigase) • Most known for being the backend for IM systems • xmpp.org
  3. 3. The GOOD • Open • Standardized by the IETF • Decentralized • Mature • Customizable • FAST!
  4. 4. The BAD • XML is very verbose • Documentation is not outlined properly • though there are efforts to make this better • Lots of presence data overhead on larger networks • No unmodified binary data transfers
  5. 5. A Simple XMPP Stanza JID resource <message from=’pradeep@xmpp.org/adium’ to=’zana@xmpp.org’> <body>This is a message</body> </message>
  6. 6. Some XMPP Features • Presence • Instant Messaging • Publish/Subscribe • Multi-User Chat • Federation • Personal Eventing, and many more...
  7. 7. The Future
  8. 8. Publish/Subscribe <iq type=’set’ to=’pubsub.xmpp.org’ from=’me@xmpp.org’> <pubsub xmlns=’http://jabber.org/protocol/pubsub’> <publish node=’apples’> <item>Fuji Apples</item> node name the pubsub namespace </publish> </pubsub> </iq> subscriber subscriber subscriber
  9. 9. Publish / Subscribe • Federated Microblogging using the Personal Eventing Protocol (PEP) • Real-time search • Real-time topic-tracking via multiple communication channels (RSS, IM etc.) • Real-time collaborative editing
  10. 10. Real-time User Interfaces • BOSH • Robust, lively interfaces for daily use • Javascript-based XMPP clients • Handlers attached to various XMPP stanzas • Present.ly, drop.io
  11. 11. The Backend
  12. 12. XMPP4R •gem install ln-xmpp4r • very full-featured • threaded, event-based • BAD: a lack of documentation, steep learning curve • Interfacing with Rails app requires an external daemon
  13. 13. strophe-ruby • gem install yong-stropheruby • based off libstrophe, a C library • event-based • can be run within a Rails app with proper timeouts and exception handling • new release soon • LOOKING FOR CONTRIBUTORS!
  14. 14. The Front-End
  15. 15. BOSH • Bi-directional streams Over Synchronous HTTP • This is not COMET, which requires a single persistent connection • Session persists over multiple connections • Full-formed HTTP requests, so works with most proxies
  16. 16. BOSH client <body/>, session BOSH connection no <body/> manager XMPP server
  17. 17. Strophe • Excellent Javascript BOSH client • written by Jack Moffit (metajack.im) • written for Chesspark • used in production at Present.ly • very, very awesome.
  18. 18. Strophe connection = new Strophe.Connection(“/http-bind”); connection.connect(“pradeep@xmpp.org”, “password”, onConnect); // this calls onMessage for each <message/> stanza connection.addHandler(onMessage, null, ‘message’, null, null, null); // this calls onPubsubEvent every time there’s a message // from a PubSub node connection.addHandler(onPubsubEvent, 'http://jabber.org/protocol/pubsub#event', 'message', null, null, null);
  19. 19. An Example
  20. 20. Present.ly (before) Client jQuery, polling Rails Custom Index DB Supporting Daemons
  21. 21. we needed something better
  22. 22. Present.ly (now) BOS H, st Client rophe- js BOSH connection manager Rails str op he -ru by eJabberd DB Supporting Daemons
  23. 23. scales beautifully
  24. 24. demo time
  25. 25. XMPP Servers • eJabberd • written in Erlang, highly scalable, actively maintained • runs in production on Present.ly, Chesspark • Jabberd2 • written in C, actively maintained • Tigase • written in Java, actively maintained • runs in production on Seesmic • Openfire • written in Java, actively maintained • large community, lots of plugins. good for basic XMPP apps • Prosody • written in Lua, very new, claims to be lightweight
  26. 26. Questions? pradeep@intridea.com twitter: @pradeep24 http://www.skyfallsin.com

×