I believe for Jruby the min and max runtimes need to bet set to 1 for
this to happen and work with config.threadsafe!

AD

On Thu, Aug 27, 2009 at 9:18 AM, Gianluca
Tessarolo<[email protected]> wrote:
> Sorry, I still can't understand how to run rails in thread safe mode under
> JRuby (one running instance supporting multiple concurrent requests).
>
> If I try to enable config.threadsafe! in config/environments/production.rb
> under Glassfish Gem my Rails application still run single threaded.
>
> Here a very simple example (environment is: glassfish gem v. 0.9.5 / jruby
> 1.3.1 / rails 2.3.3 / ubuntu 9.04 / notebook centrino dual core / 2gb Ram):
>
> rails concurrent
> cd concurrent
> script/generate controller test test
>
> edit app/controllers/test_controller.rb, modify source as follow:
>
> class TestController < ApplicationController
>   def test
>     @value = Time.now
>     sleep 10
>   end
> end
>
> edit app/views/test/test.html.erb, modify source as follow:
>
> <%= @value %>
>
> edit config/environments/production.rb, uncomment last line as follow:
>
> config.threadsafe!
>
> edit config/environemt.rbm uncomment frameworks line as follow (no database,
> resource, mail support for this very simple
> test...):
>
> config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
>
> Now run:
>
> jruby -S gfrake config
>
> edit config/glassfish.yml, modify config as follow (notice 4 runtime
> instances !):
>
> environment: production
> jruby-runtime-pool:
> initial: 4
> min: 4
> max: 4
>
> And finally start glassfish gem:
>
> jruby -S glassfish
>
> Now, if you try to call 4 times (concurrently) the following url...
>
> http://localhost:3000/test/test
>
> ...you must wait 40 seconds for the 4th response...
>
> This is a wrong behaviour because trying the same test under phusion
> passenger I wait only 10 seconds for the 4th response
> (in fact passenger start up 4 rails processes, 1 for each concurrent
> request)...
>
> I want to know if is it possible to run Rails with only one running instance
> supporting multiple concurrent requests...
>
> Many thanks in advance...
>
> At 10:45 PM -0700 8/15/09, AlwaysCharging wrote:
>
>
> Why would anyone use ruby over Jruby?  I'm admittedly a noob about all
> this stuff, but from what I've read jruby seems superior to ruby and
> quite a bit faster.  What would be the disadvantages of JRuby?  I man
> it's possible to use it with rails now, and JRuby is what's used by
> default in netbeans (which is the ide I think I've settled on).  So
> why not JRuby?  Would the tutorials be all that different?
>
>
> I use both MRI and JRuby -- often at the same time in the same
> project when developing.
>
> One advantage I didn't see in the thread so for MRI is that the
> interpreter starts fast. This is great when starting lots of small
> tasks from the console.
>
> Here's a couple of pluses for JRuby that I haven't seen mentioned:
>
> 1) It is very easy to make multiple, complete, and isolated Ruby
> installation using JRuby. I know there are some tools to make this
> easier in MRI -- I even wrote a simple one -- but this is trivial in
> JRuby.
>
> 2) For some rendering operations in development mode JRuby can be 20x
> faster.
>
> This is a strange result -- in general I've found JRuby to be about
> twice as fast as MRI in production ... but I'd never seen this result
> before ...
>
> I've got a complex Rails application for authoring secondary science
> investigations and one of the render tasks generates a composite xml
> document that represents all of the objects in an investigation.
> Right now the largest investigation is about 350k rendered into xml
> and represents over 1100 objects. Roughly that corresponds to about
> 1100 partial calls.
>
> I have not done ANY work on improving performance in the rendering
> speed yet (lots of partials calling partials) and noticed that the
> render speed when running in MRI in development mode has gotten very
> long as authors have finally started making real investigations.
>
> I put together a benchmark measuring the time to render 11
> investigations in xml.
>
> The JRuby results were quite impressive:
>
>            Development   Production
> =======================================
> MRI:        849s           30s
> JRuby:       35s           18s
>
> The rendering is done with HAML.
>
> I have no idea why rendering in dev mode in MRI is SO slow.
>
> There's obviously a problem somewhere in the interaction with Rails,
> my code, MRI and development mode. But the fact that JRuby running in
> development mode renders all 11 Investigations into xml only 15%
> slower than MRI in production is great.  It also means that when I am
> testing or developing these features in the app I run my dev server
> in JRuby.
>
> While I plan to work on performance later in most cases in production
> the Investigations will be frozen and the xml doc will be served from
> a page cache -- so performance improvements in rendering are not on
> the critical path for the production app.
>
> This is running on Mac OS X 10.5.8 and Rails 2.3.3
>
> MRI and JRuby versions:
>
> $ jruby -v
> jruby 1.4.0dev (ruby 1.8.7p174) (2009-08-09 6586) (Java HotSpot(TM)
> Client VM 1.5.0_19) [i386-java]
>
> $ ruby -v
> ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0]
>
> more details:
>
> http://groups.google.com/group/cc-developers/browse_thread/thread/af4ca01be8eb41ab?hl=en
>
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to