I'd want to implement a Real-time chat for my Rails app but I can't really host the server which handles the sockets. I've tried Faye but it needs a server. I've also heard of pusher but it's limited to 20 users at a time on the chat and I can't really be sure they won't be more.

I've thought of IRC but I think I can't really embed it into a rails app, maybe it needs sockets...

How can I implement a real-time chat without owning a server?

  • There's a lot of great solutions, but none that will work without a server to host them on. – Andrew Nov 15 '11 at 1:02

You can't implement real-time chat without having a server capable of coordinating it in real time. Typical shared host web server setups are not suitable for this sort of thing -- they usually don't have the right sorts of things installed and typically don't have the umph to handle the traffic in any case. So typically you'll need to secure at least your own VPS especially if you care about performance and reliability.


If you want to try something new, you can use :

For you, cramp might be useful. I have created a basic demo for a peer to peer chat. It is not for production, but you can find out enough information :

em-wesocket Chat Demo

It is done with em-websocket and socket.io.

In this demo, I am not using redis but with redis you can achieve more scalability and persistence.

Cramp or nodejs will work for you.

  • Cramp seems very promising for Ruby developers. – garbage collection Oct 15 '12 at 18:03
  • You'll most likely need a server, but Rails can handle websockets marvelously. Check out this gem to get some real time behavior into your Rails app: github.com/so-entangled/rails – weltschmerz Feb 13 '15 at 8:54

You can try out PubNub :

PubNub is considered a Web Push Engine able to push (or stream) any textual data in real-time data push to any types of clients across the Internet. PubNub solves all the complexity of pushing data in a scalable, secure, efficient, reliable and portable way. On the client side, APIs are provided so that it is very easy to build Bidirectional Data Push Apps (transforming your existing client or creating a new one from scratch). A powerful HTML5 library makes it possible to push data updates to Mobile Phones, Tablets and Web Pages in real-time data push through a zero-install client.


Why are you not able to host it yourself? Is it the cost of hosting?

You could try Socket.IO running on Node.JS, hosted on a free Heroku account. The HTML would remain in your rails app, but the "web socket server" (technically a long-polling server in the case of Heroku) would be running on a free Heroku account.

Other than that, I'm not sure what you are asking. In order to host a website, you need a web host. In order to host a chat server, you need a server to host it on.


Web sockets are by far the most efficient way to handle chat functionalities. As a framework, Rails is not very good at handling asynchronous events and therefore establishing a socket connection to a Rails application is almost impossible. There are many solutions that are designed to handle this kind of problem. As Andrew said, Frameworks such as Node.js with Socket.IO would suffice, or, if you want to stick with Ruby, Cramp, async_sinatra, or Goliath framework are all great solutions but it would be super awesome to continue.

If you wanted to use Rails for your application's logic and also have the benefits of some kind of asynchronous event handling with publishing and subscribing you will need to use something like Private Pub Gem which is built on top of Faye and makes it dead simple to publish and subscribe to real-time events in a Rails app.

I have tried to put together a Gmail-like instant message chat application in a rails 4 app. Check out this tutorial. Hope that helps shed some light on the same.

Not the answer you're looking for? Browse other questions tagged or ask your own question.