BenchmarkForRails Viewer Ruby on Rails plugin (with Juggernaut's server push technology). 8

Posted by Daniel Wanja Sun, 06 Jan 2008 05:08:17 GMT

Release early, release often they say. I don’t know if I’m going to release often but this is very early for this project. In fact yesterday I was testing the excellent Juggernaut plugin for Ruby on Rails, a “server push technology”, created by Alex McCaw and at the same time I was trying out the BenchmarkForRails plugin. The BenchmarkForRails plugin adds some detailed log information about the time breakdown for a request in the following format:
- [0.0954] GET /categories -----------------------
   0.0791 action
   0.0098 development mode
   0.0026 finders
   0.0003 session
   0.0001 rendering
   0.0001 filters
------------------------------ BenchmarkForRails -

Of course I had to look how it was implemented and it didn’t take me long, (once I overcame a self inflicted issue for which Alex McCaw helped me out. Thanks man!), to try to combine the BenchmarkForRails, Juggernaut, and Adobe’s Flex to create a little Benchmark Viewer that looks as follows:

http://localhost:3000/benchmark/BenchmarkForRails.html 20080105_bencmarkforrailsviewer.jpg

Note: that’s the only view currently supported. The ‘last’, ‘last 5’, ‘last’, ‘last 5 (same), selection will provide different views of your requests but this functionality isn’t yet coded. Also filtering by controller and action would be nice.

Like I said this is very early but combining Benchmarking with server push technology offers quite some potential, but let’s keep it simple for now…

Well, the installation is not as simple as it could be for the moment I provided some steps here after. To run the application simply start the Juggernaut push server, start you server as usual, and you will see the time details of each request in the viewer. The time is color coded to indicate wether the time was slower (red), faster (green), or same (white) than the previous request of the same type (controller, action, method).

Note for the installation you must use the http://juggernaut.rubyforge.org/svn/branches/juggernaut_1.0/ version. This is a more recent version than trunk and Alex will put it to trunk soon. Also the Flex client uses the default port 5001 to talk to the push server. If that’s an issue for you then you are out of luck. Not for long, as this is the next thing I will change in the Flex application.

INSTALLATION

You need the following plugins: benchmarkforrails, juggernaut, and benchmarkforrails_viewer

a) benchmarkforrails
$ svn export http://benchmarkforrails.googlecode.com/svn/trunk vendor/plugins/benchmarkforrails
b) juggernaut
$ svn export http://juggernaut.rubyforge.org/svn/branches/juggernaut_1.0/ vendor/plugins/juggernaut
$ rake juggernaut:reinstall  
This creates the conf/juggernaut.yml and conf/juggernaut_hosts.yml file. Note juggernaut has detailed installation instruction. But in short you need the json and the eventmachine gems. c) benchmarkforrails_viewer
$ svn export http://onrails.googlecode.com/svn/trunk/plugins/benchmarkforrails_viewer vendor/plugins/benchmarkforrails_viewer
$ rake benchmarkforrails_viewer:reinstall
The later copies the UI files into the public/benchmark folder.

RUNNING THE VIEWER

1) Start the juggernaut push_server.
    cd vendor/plugins/juggernaut/media/
    # The first time you need to generate a config file using:
     ruby juggernaut -g
    # Start the push_server
     ruby juggernaut 

2) In a different terminal start your rails server, ./script/server

3) Start the BenchmarkForRails Viewer: http://localhost:3000/benchmark/BenchmarkForRails.html Note you need the Flash Player 9 installed.

4) Run your application (only in development) as usual and see the request benchmarks in the viewer.

The next functionality I would like to add is to make the port configurable in the Flex application, to add different views to view the requests. I shall also contact the guys that developed the BenchmarkForRails plugin to see if they could add a standard ways of plugging different reporting engines. But more importantly I would like to get your feedback. Let me know if this worked for you and if what else you would expect from such a viewer. I am sure I will hear from you if I forgot some details….Yea, like I think this only works for Rails 2.

Enjoy! Daniel

Comments

Leave a response

  1. Tony Hillerson Mon, 07 Jan 2008 02:47:41 GMT

    This is awesome! I think I may use it for a project at work right now.

  2. Cox Thu, 24 Jan 2008 14:49:29 GMT

    Are these all plugins (benchmarkforrails, juggernaut, and benchmarkforrails_viewer) or do I need some others?

  3. Daniel Wanja Thu, 24 Jan 2008 15:04:59 GMT

    Juggernaut requires the json and eventmachine plugins.

  4. Oliver Thu, 31 Jan 2008 09:45:03 GMT

    Didn’t work for me, unable to load eventmachine, even after a gem install eventmachine, the directory plugin/uggernaut/media isn’t there either.

    I abanndonned ;( waiting for an update.

  5. Oliver Thu, 31 Jan 2008 09:45:03 GMT

    Didn’t work for me, unable to load eventmachine, even after a gem install eventmachine, the directory plugin/uggernaut/media isn’t there either.

    I abanndonned ;( waiting for an update.

  6. Daniel Wanja Thu, 31 Jan 2008 14:31:07 GMT

    Hi Oliver,

    It looks like Juggernaut changed, so I have to try with the latest Juggernaut. I know Alex is turning it into a gem…so I’ll have to see how use it with it and where he put the push server.

  7. vishwam@mangospring.com Sat, 02 Feb 2008 14:19:33 GMT

    Hey Daniel,

    Would be great if you could update this to work with the changed Juggernaut soon…

    Additionally any chance you could get this to work with Rails 1.2.. would be awesome if it did as I would love to try it out in one my products developed on Rails 1.2…

    Appreciate the help.

  8. Daniel Wanja Sat, 02 Feb 2008 15:30:49 GMT

    I will update the BenchmakrForRailsViewer for the latest Juggernaut, but I won’t try to make it work for Rails 1.2. Feel free to jump in if you want to see it work for 1.2.

Comments