rails threads / contexts / fastcgi - can someone explain ???


I'm not a FastCGI expert, but I'll try to answer your questions as best I can.

Would someone be able to explain how ruby class/object contexts work
from the point of view of a deployed rails application using FASTCGI and
noting there are multiple Ruby processes running (say on dreamhost for
example). Some questions to help clarify what I'm trying to understand:

a) how do incoming URL requests get spread across the multiple Ruby
processes (let's say there are 5 processes)?

By whatever's in front of the processes. If you're using
lighttpd/fastcgi, for example, lighttpd will do the balancing across
the multiple rails fastcgi listeners.

b) What component organising/manages this? (e.g. plugin in apache?)

c) is there any 'stickness' that occurs? i.e. where a request from
person A that goes to ruby process 2 the first time will go to process 2
again for the next person A request (I assume no?)

That's going to depend on the particular implementation. I haven't
seen it implemented anywhere, but that doesn't mean that someone
hasn't done so.

d) is there any sharing of contexts between the ruby processes? i.e.
Can a ruby class variable be "seen" across processes?

By default, no. You can use an in-memory cache accessible by all
listeners (on the same box).

e) is there any equivalent to the java static class variable (which can
be accessed from any user request coming in which is being hosted within
the same web-container on the same JVM)? I understand there isn't an
equivalent in ruby?

I'm not sure what you're asking here. There are class variables in ruby.

f) does the running ruby process handle multiple simultaneous user
requests at the same time? i.e. is it operating in a multi-threaded

It doesn't.

g) If so (for last question) is there any scope for collisions when
using class variables (@@variable), or is each user request (i.e. each
HTTP request) totally isolated from every other request at the
ruby/rails application level? (of course the database would be shared).
i.e. could both users/requests share the same class variable somehow??

Again, I'm not sure what you're asking. Rails runs single-threaded.

h) what non-database caching raw ruby techniques are there for same
caching a bunch of constants stored in a properties type file - perhaps
put the properties/configuration setting in a ruby file itself as
constants. Is it effectively already "cached" once it is "require"ed
via ruby then holding it in memory? or does ruby re-load that file each

Put config stuff in the environment files. In production mode those
don't get reloaded.