Slide 1

Slide 1 text

Chat implementation in Ruby and Websocket Cam Huynh (@huynhquancam)

Slide 2

Slide 2 text

Cam Huynh Software Enbugger @ Dadadee

Slide 3

Slide 3 text

actioncable

Slide 4

Slide 4 text

What this talk is about? ● What we experienced during the development of Dadadee chat system. ● Technologies we’ve considered during the development. ● Problems we faced and how we solved them.

Slide 5

Slide 5 text

Functionality Requirement ● Integrate realtime chat function to our existing Android and iOS app. ● Web services built upon Ruby on Rails.

Slide 6

Slide 6 text

Our Back-end Resources ● Two Plain Old Ruby Developers. ● Our application built upon Ruby on Rails. ● Limited NodeJS experience.

Slide 7

Slide 7 text

Technology taken into considerations ● XMPP. ● Pure NodeJS with Socket.IO ● Long polling (Message Bus) in Ruby.

Slide 8

Slide 8 text

Socket.IO Pros: ● Rich documentations and guides. ● Easy to start off, fast development. ● Support both of Android and iOS (by native JS executor). ● 23k stars on Github. Cons: ● Rewrite the domain logics in Javascript. ● Lack of experience in Javascript. ● Callback Hell. > Manage logics in Javascript is the most horrible thing Rubyists could think of.

Slide 9

Slide 9 text

Message Bus Pros: * Extracted from Discourse, by Sam Saffron. * Written in Ruby. * Awesome DSL. Cons: * Have no SDKs for Android and iOS yet, and our mobile guys have ZERO experience in Javascript. * Only polling and long polling, no websocket support. * Leverage on Redis PUBSUB, no other backend supported.

Slide 10

Slide 10 text

Pros ● Simple installation. ● Robust, well-tested. ● Mature and widely adopted. ● iOS and Android clients are available. > We decided to give OpenFire a try. OpenFire (XMPP) Cons ● We have zero Java experience ● Bad, complicated management user interface. ● Bad message history archives. ● Poor RESTful (so-called) API. ● Troublesome clustering. ● Inactive development. > The failure of the year.

Slide 11

Slide 11 text

we are stuck! SocketIO / MessageBus: too tedious and risky. OpenFire (XMPP): the failure of the year.

Slide 12

Slide 12 text

https://github.com/duythinht/chat-system

Slide 13

Slide 13 text

RESTful Web Service Push Service Client POST messages/ Websocket PUBSUB MQ publish subscribe

Slide 14

Slide 14 text

Existing RoR web service Socket.IO Client POST messages/ Websocket Redis publish subscribe

Slide 15

Slide 15 text

The RESTful approach Utilize current codebase, domain logics, service. Better extractability. Microservice. Good Testability.

Slide 16

Slide 16 text

Demo / Q&A

Slide 17

Slide 17 text

https://github.com/huynhquancam/chat-stack

Slide 18

Slide 18 text

thanks!