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…
…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…