From: Michael Granger Date: 2008-02-16T16:42:41+09:00 Subject: Re: How to put a Ruby website online without rails On Feb 15, 2008, at 3:11 PM, s.ross wrote: >>> You probably can't even create >>> multiple threads running ruby safely (as opposed to creating >>> multiple >>> ruby threads inside one native thread of execution as is done in the >>> interpreter). >> >> [...] >> I'd be happy to provide further details if anyone's interested. I'm >> just getting tired of the FUD and hastily-posted conjecture about >> what constitutes appropriate technology for building web >> applications. > > Yes, I am interested. There is a widely-held perception based on > information from well-respected Rubyists and Rails people that > mod_ruby has problems related to managing re-entrant code. mod_ruby, at its core, is two things: a Ruby interpreter embedded into Apache that can be called into during the various stages of a request, and a collection of classes that express the Apache API in Ruby. The interpreter that is embedded is neither more nor less re-entrant than that run from the command line, which is to say that it isn't for any interpreter up to and including 1.8.6. I run mod_ruby apps under the Apache "pre-fork" MPM, so perhaps there are issues with the interpreter's re-entrancy when running under the "worker" or "event" MPMs -- but then again the person I was replying to didn't mention MPMs at all, he just stated that mod_ruby was to be avoided altogether. Does the common complaint about mod_ruby really boil down to Ruby's lack of re-entrancy? Or maybe this is just a re-phrasing of the "shared hosting problem"? I mentioned in the previous post that mod_ruby is probably not suitable for running untrusted code or in shared environments without additional partitioning, but I still don't think that describes the majority of situations, and it certainly doesn't warrant dismissal of the whole package outright. If any of the aforementioned "well-respected Rubyists and Rails people" have additional light to shed on this, I'd love to know where this "widely-held perception" is coming from. I've been using mod_ruby since late 2002, and I haven't happened upon anything that would indicate that it deserves the reputation it seems to have gained. > This might translate to: "Most users don't have the background to > set mutexes so they will eventually stomp on data that's not thread- > save" but it might also translate to: "This ain't mod_php, guys. You > can do bad things and never know until it's too late." I'm still not convinced that there's lots of threaded web applications out there that require mutexes and the like, but sure: with great power comes great responsibility. You have to program with more discipline when you're writing applications that run for long periods of time and share an ObjectSpace with other code, but that's what Module and Kernel#load('myfile', true) are for (among other things of course). Programmers who splat their code all over the Ruby ObjectSpace, can't resist the urge to reopen every core class under the sun to inject their own pseudo-clever trinket methods, and can't be bothered to namespace their class libraries should probably stick to environments where their crap runs in a safe little box that can be kill -9ed when it inevitably hangs or gets too bloated. > So, yes, a clarification would be extremely useful. I actually meant if anyone wants more specific details about how to write applications under mod_ruby, then I'd be happy to furnish them, but I realize I didn't state that quite clearly enough. I hope this sufficed for a clarification anyway. -- Michael Granger Rubymage, Architect, Believer The FaerieMUD Consortium