[Rails] Webrick in production?

Zed Shaw zedshaw at zedshaw.com
Sat Mar 4 16:04:44 GMT 2006


On 3/4/06 7:14 AM, "Justin Forder" <justin at justinforder.me.uk> wrote:

> Ben Munat wrote:
>> Eric Hodel wrote:
>>> On Feb 27, 2006, at 9:55 PM, Ben Munat wrote:
>>>> So what about the mythical "mutex on each request" that WEBrick has?
>>> 
>>> I don't know about Rails, but no such thing exists in WEBrick.  (Note
>>> that I'm not using WEBrick to serve Rails requests, I'm using it for
>>> "image hits".)
>> 
>> Duh... helps if I read more carefully. The passage in AWDWR is: [WEBrick
>> is] not a particulary attractive approach for heavy-duty use. One of the
>> reasons is the lack of thread safety in *ActionPack* (emphasis mine),
>> which forces WEBrick to place a mutex at the gate of dynamic requests..."
>> 
>> So, it is a problem in rails...... on the other hand, this is a rails
>> list so I can see how I'd be thinking about that. :-)
> 
> As I understand it, the mutex is in Rails, and it affects Mongrel in
> exactly the same way that it affects WEBrick.
> 

Yes, Mongrel has to use a "grand mutex" around the Dispatcher.dispatch in
order to prevent Rails from going crazy.  Rails just isn't thread safe.

One thing you can do in both Mongrel (and WEBrick) is if there's a
particular little part of your Rails application that needs to run very
fast, then write a handler that runs right inside Mongrel.  This then moves
the processing out reducing the overhead and giving you full threaded
operation (which you have to be careful of yourself).

Zed A. Shaw
http://www.zedshaw.com/



More information about the Rails mailing list