The Source for Java Technology Collaboration
User: Password:



Arun Gupta

Arun Gupta's Blog

Ruby/JRuby Process Models Explained

Posted by arungupta on August 20, 2007 at 09:31 AM | Comments (5)

In the JRuby Hackday, Nick Sieger described the process models of a Rails application deployed using

In this blog entry I'm capturing a brain dump from him after the event. The images below shows process models in each of the above mentioned approaches. The containment of boxes in each image is shown in terms of the application logic instead of the process. The legend followed in the images is as follows:

In the first approach, a C-based Ruby on Rails application is front-ended by an HTTP library - Mongrel. The typical app will be deployed on a cluster of Mongrel servers - provided by Mongrel_cluster plug-in.

This plug-in configure and control the several Mongrel servers. Mongrel is largely written in Ruby and uses native C for HTTP request parsing. Each instance of Mongrel starts a Ruby interpreter that listens on a server socket. The Ruby script has a Mongrel handler that queues up multiple requests from the client and passes the state, one at a time, to a Rails instance (that is by design single threaded).

For a Mongrel cluster, multiple Ruby interpreters are started as an OS process.

The second approach shows how a Rails application may be deployed using JRuby. This is a transition approach between traditional C-based Ruby on Mongrel deployment and JRuby-based deployment on GlassFish.

Mongrel JCluster is an update to Mongrel_cluster that only runs in JRuby. The biggest difference is that it starts only one Java Virtual Machine (JVM) that starts several Mongrels in the same JVM by spawning multiple JRuby processes, one in each thread. As in traditional approach, each Mongrel listens to the request on a server socket and passes the request state to Rails.

For a Mongrel JCluster, only one JVM is started as an OS process.

The last approach shows how a JRuby application may be deployed on GlassFish. With this approach, there are two modes to deploy an application.

In the first case, Goldspike plug-in is installed in a standard Rails application. This plug-in adds the "war:*" rake targets to a Rails project. Invoking "war:standalone:create" rake target creates a WAR file containing all the dependent JRuby and Rails libraries. This WAR file can then be deployed in GlassFish. The "web.xml" in this WAR file contains a Servlet (org.jruby.webapp.RailsServlet) that translates data from Servlet request to Rails dispatcher.
In the second case, the Grizzly connector understands the request format and dispatch it directly to a pre-configured JRuby installation (updated with the Rails gem). In both the cases, there is only one JVM running as the OS process for GlassFish. The main advantage of the second approach is that it by-passes the web application processing and delegate the request directly to the Rails framework.

A detailed screencast of the first GlassFish case (Goldspike/JRuby) is available here and for the second case (Grizzly/JRuby) is documented here.

Technorati: ruby jruby jrubyonglassfish glassfish grizzly goldspike rubyonrails ror


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first)

  • hi arun,

    goldspikeServet : neat.

    Is there a download packet for the same ? It will be nice if you could
    1) bundle netbeans, glassfish and Goldspike all in one easily downloadable packet.

    2) add a Wizard and WizardManager (somewhat like ATL in Visual Studio) that lets one to manage the Rails componeents/pages from within Netbeans.

    BR,
    ~A

    Posted by: anjanb2 on August 20, 2007 at 03:06 PM

  • Anyone care to produce scalability and performance metrics for the various process deployment models?

    Posted by: craig514miller on August 20, 2007 at 03:46 PM

  • anjanb2, NetBeans and GlassFish are already available as a single bundle from netbeans.org. We are already working on including Goldspike plugin as part of NetBeans as well. Do you have any suggestions on how you'd like it to be exposed because this is a plugin, not a gem ?

    Posted by: arungupta on August 21, 2007 at 01:27 PM

  • craig, I'm not aware of any such metrics. Please drop a note if you are aware.

    Posted by: arungupta on August 21, 2007 at 01:28 PM

  • Craig, Arun - here is a link to JRuby on Glassfish performance test: http://vysnu.com/log/2007/07/08/jruby-glassfish-investigation.html Pretty cool. What's even cooler, although a bit off topic, is that one developer found a way to connect to EJBs from Rails! The whole idea of running RoR app on Java App Server and being able to connect to Java code opens up very interesting possibilities. Here is the link: http://blog.dannynet.net/archives/63 Eugene

    Posted by: eugeneonjavanet on August 24, 2007 at 09:54 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds