Problem with multithreading on Ruby On Rail

Hi,

first of all, sorry for my english.

to start, here my config : Server linux : ubuntu 8.4 Rails : 2.3.4 Ruby : 1.8.7 (2010-06-23 patchlevel 299) [x86_64-linux]

I wanted to test the charge capacity of my server, and I saw a problem with the multithrearding on Ror.

Here the config file on the server config/environments/development.rb Code :

what are we seeing? - 5 process run together - Ruby take the same time for each process (760 ms) - BUT : RoR wait the end of each process before answer to client.

finally : I think, there is a probleme somewhere. but WHERE?? could you help me please?

Rails runs single-threadedly by default. config.threadsafe! (in one of your environment configuration file) will enable more than one request to be processed at a time although limitations of MRI's threadeding mean you might not see the difference you expect (and i think earlier versions of mongrel only even dispatch one request to rails at a time, because rails used to be non threadsafe)

Fred

Frederick Cheung wrote:

what are we seeing? - 5 process run together - Ruby take the same time for each process (760 ms) - BUT : RoR wait the end of each process before answer to client.

finally : I think, there is a probleme somewhere. but WHERE?? could you help me please?

Rails runs single-threadedly by default. config.threadsafe! (in one of your environment configuration file) will enable more than one request to be processed at a time although limitations of MRI's threadeding mean you might not see the difference you expect (and i think earlier versions of mongrel only even dispatch one request to rails at a time, because rails used to be non threadsafe)

Fred

thank you.

I comment this line : config.cache_classes = false

In the config, And I see it work better. But, could you answer to this question :

When only one process run, the client wait 0.907 sec. When 2 process run together, each client wait 1.705 sec. When 5 process run together, each client wait 4.073 sec.

Whereas ruby take 0.760 sec each time, for all process in all configuration.

Why?

I comment this line : config.cache_classes = false

In the config, And I see it work better.

You definitely want that - class reloading is non threadsafe.

But, could you answer to this question :

When only one process run, the client wait 0.907 sec. When 2 process run together, each client wait 1.705 sec. When 5 process run together, each client wait 4.073 sec.

I checked mongrel's source code - it's still got that mutex inside the rails dispatcher ( a relic really from when that was still needed) so it will never dispatch more than one request to rails at a time.

Fred

Frederick Cheung wrote: