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

  • 5,618 views
Uploaded on

First given at LARubyConf 2009

First given at LARubyConf 2009

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
5,618
On Slideshare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
0
Comments
0
Likes
19

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide






















































Transcript

  • 1. Fast, Scalable Front/Back-end Services using Ruby, Rails and XMPP Pradeep Elankumaran pradeep@intridea.com twitter: @pradeep24
  • 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. The GOOD • Open • Standardized by the IETF • Decentralized • Mature • Customizable • FAST!
  • 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. A Simple XMPP Stanza JID resource <message from=’pradeep@xmpp.org/adium’ to=’zana@xmpp.org’> <body>This is a message</body> </message>
  • 6. Some XMPP Features • Presence • Instant Messaging • Publish/Subscribe • Multi-User Chat • Federation • Personal Eventing, and many more...
  • 7. The Future
  • 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. 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. 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. The Backend
  • 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. 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. The Front-End
  • 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. BOSH client <body/>, session BOSH connection no <body/> manager XMPP server
  • 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. 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. An Example
  • 20. Present.ly (before) Client jQuery, polling Rails Custom Index DB Supporting Daemons
  • 21. we needed something better
  • 22. Present.ly (now) BOS H, st Client rophe- js BOSH connection manager Rails str op he -ru by eJabberd DB Supporting Daemons
  • 23. scales beautifully
  • 24. demo time
  • 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. Questions? pradeep@intridea.com twitter: @pradeep24 http://www.skyfallsin.com