Getting Started With JRuby on Rails for Sun GlassFish Enterprise Server v3 Prelude

Configuring JRuby Runtime Pool

The Sun GlassFish Enterprise Server v3 Prelude provides a JRuby runtime pool to allow servicing of multiple concurrent requests. However Rails is not currently thread-safe, and while JRuby is able to take advantage of Java's native threading, Rails cannot benefit from it. Each JRuby runtime runs a single instance of Rails, and requests are handed off to whichever instance happens to be available at the time of the request.

JRuby runtime pool is configured in <AS_INSTALL>/domains/domain1/config/domain.xml file. Edit the file and add the elements below with the values that you want the runtime to be configured with as indicated.

<java-config>
<jvm-options>-Djruby.runtime.min=1</jvm-options>
<jvm-options>-Djruby.runtime=2</jvm-options>
<jvm-options>-Djruby.runtime.max=3</jvm-options>
</java-config>

The properties of the above elements are explained as follows:

The dynamic runtime pool maintains itself with the minimum number of runtimes possible, to allow consistent and fast runtime access for the requesting application. The pool may take a initial runtime value, but that value is not used after pool creation.