JuggerNaut - Push Server for Rails

14 Mar 2008

When we build a web page that contains data which gets updated very frequently (eg: Share price of Google, or score of a live cricket match), it would be extremely useful if we could 'push' data into the webpage, without the user having to 'pull' the data by reloading the page or requesting explicitly.

Juggernaut is a Ruby on Rails plugin that helps to implement this 'push' mechanism. Comet is the widely accepted technology for doing the same. Juggernaut claims to have a few advantages over comet. Details can be found here.

Apart from the Rails application, juggernaut runs a separate push server, which maintains persistent socket connection with all connected clients. Ruby app sends data to this push server, which pushes the data to all connected clients.

Juggernaut initiates a flash xmlsocket between server and browser allowing real time communication between the two. The open socket connection allows the server to ‘push’ base64 encoded javascript to the browser which is subsequently decoded and evaluated.


Installation and configuration of Juggernaut are explained in detail in the Juggrenaut page.

I tried to build a simple Juggernaut-Rails application that would push the current playing song name in my system(rails app runs on the same machine). It was fairly simple, current playing song name was extracted using the Dbus interface of Rhythmbox music player (More details on this can be found in my article on IPC with Dbus. Once the songname was obtained, pushing it to the browsers required only the following code in the controller:

 render :juggernaut do |page|
      page.replacehtml 'songname', "<b> #{song_name} </b>"