Recently I am deploying my Rails 3 project on jruby (1.6.4) platform for protecting ruby source code.
I use warble to package my rails project into a war file for Apache Tomcat(6), then use NGINX as front web server to proxy backend tomcat.
I found JRuby took high memery and cpu during application initialization and this will take almost three minutes.
I want to know to how to config jruby (such as JAVA_OPTS) and my rails project to reduce memery and cpu occupation and quickly finishing startup.
And NGINX proxy backend tomcat is a suitable way to deploy rails on jruby project?
qichunren@qichunren-desktop:~/code/ntdeck$ java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
qichunren@qichunren-desktop:~/code/ntdeck$ jruby -v
jruby 1.6.4 (ruby-1.8.7-p330) (2011-08-23 17ea768) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_26) [linux-amd64-java]
apache-tomcat-6.0.33
nginx-1.0.6
ubuntu 11
Probably the best thing you can do is to make sure to set jruby.min.runtimes = jruby.max.runtimes = 1, and run Rails in threadsafe mode. It will reduce initialization time since you only have to boot a single runtime, and reduce memory overhead of multiple runtimes.
Finally, if you find a steady-state memory level for the application, you might want to explicitly state the maximum memory to the JVM in the Tomcat settings.