I have a JRuby on Rails app that was not able to handle a production
load of ~300 requests/min, and I’d like some direction troubleshooting
it. I know of several things that are inefficient, but need to figure
out what the best bang-for-the buck would be.
Conceptually it’s a simple app: It receives a search term, connects to
a Google Custom Search account, receives an XML response, parses it,
and displays the results. A second AJAX request pops in a sidebar with
related items queried from a database. The first request takes the
It’s Rails 2.3.5 and JRuby 1.5.2 being deployed as a .war to a single
instance of Tomcat 6 on a Sun T5250/Solaris with 16 CPUs and 256GB
RAM, though this is shared by many other apps, some in separate
A few minutes under load and it was consuming 8GB(!) of RAM and
running extremely slowly. The page was taking over 30 seconds to
appear, but the in-app timers and New Relic were both showing “normal”
execution times of a little over 1 second, as if there was some
queuing going on or something outside the controller holding things
- I know I should bring it up to JRuby 1.5.6 at least, and I’m sure
1.6.0 will have additional improvements. I’m sure there may also be
improvements to JRuby-Rack and Warbler since we first incorporated
them into the project. Is there anything in the newer stack likely to
make a huge difference?
- Warbler is configured as threadsafe but the runtimes are set to min/
max of 2 and 4. New Relic is showing 4 runtimes. I haven’t found much
guidance for these settings (especially the interaction of threadsafe
with runtimes), and am not sure if setting them to 1 and 1 would
improve things? Or should they go higher? What’s the downside to
setting this to a very large number?
- The memory consumption concerns me, and I’m wondering if it’s maxing
out at the measured 2GB/runtime. The app uses REXML (actually JREXML,
but it doesn’t seem to make a difference) and I have a feeling this
should be swapped out immediately with Nokogiri or a Java XML parser.
- We’ve found that the Sun doesn’t have a lot of raw speed but should
scale out well IF I’m taking advantage of threading and multiple CPUs.
Should I be using multiple Tomcat instances and balance between them
Any guidance toward the most obvious problems, or additional things I
haven’t thought of, would be appreciated.