Sun GlassFish Enterprise Server v3 Scripting Framework Guide

Configuring JRuby Runtime Pool

The Sun GlassFish Enterprise Server v3 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.

The JRuby properties in the above configuration 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.

The JRuby runtime pool values can be set either at container level or at deploy time. To set the runtime pool values at container level, use the following asadmin command:

asadmin configure-jruby-container --jruby-runtime=2 --jruby-runtime-min=1 --jruby-runtime-max=3

Note that each of the above properties can be set separately at a time. To set the runtime pool values at deploy time use the following asadmin command:

asadmin deploy --property jruby-runtime=2:jruby-runtime-min=1:jruby-runtime-max=3

Each of the above properties also can be set at a time or at the same time. If both settings are used, deploy time settings take precedence over container runtime settings.