简体   繁体   English

如何在jruby上优化rails项目?

[英]How to optimize rails project on jruby?

Recently I am deploying my Rails 3 project on jruby (1.6.4) platform for protecting ruby source code. 最近我在jruby(1.6.4)平台上部署我的Rails 3项目来保护ruby源代码。

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. 我使用warble将我的rails项目打包成Apache Tomcat(6)的war文件,然后使用NGINX作为前端Web服务器来代理后端tomcat。

I found JRuby took high memery and cpu during application initialization and this will take almost three minutes. 我发现JRuby在应用程序初始化期间采用了高memery和cpu,这将花费将近三分钟。

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. 我想知道如何配置jruby(如JAVA_OPTS )和我的rails项目,以减少memery和cpu职业,并快速完成启动。

And NGINX proxy backend tomcat is a suitable way to deploy rails on jruby project? 而NGINX代理后端tomcat是在jruby项目上部署rails的合适方式吗?


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. 您可以做的最好的事情是确保设置jruby.min.runtimes = jruby.max.runtimes = 1,并在线程安全模式下运行Rails。 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. 最后,如果您发现应用程序的稳态内存级别,您可能希望在Tomcat设置中明确说明JVM的最大内存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM