Scaling and class methods

Hey George-

  A new controller class is instantiated for each request. But class variables are global for the whole inheritance chain of classes that contain them. And rails is not thread safe so there is always a mutex that ensures that only one request is ever running through the rails dispatcher at once. So as long as you make absolutely certain that the @@classvariable gets set on each and every request, you will not run into any problems.

Cheers- -- Ezra Zygmuntowicz-- Lead Rails Evangelist -- ez@engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)

Hi~

Awesome thanks Ezra, the class variable is always set on each request. If you're running say 20 FastCGI proccesses do they each run their own ruby instance or are they all using one ruby instance with locking as you described?

Yes, each fcgi or mongrel backend runs a copy of rails in its own ruby process/interpreter.

Just checked out your hosting btw - looks pretty good!

Thanks!

-- Ezra Zygmuntowicz-- Lead Rails Evangelist -- ez@engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)