[Mongrel] mongrel becoming unresponsive
wyhaines at gmail.com
Tue May 8 11:47:12 EDT 2007
On 5/8/07, Pete DeLaurentis <pete at nextengine.com> wrote:
> Thanks for the explanation Luis. This makes good sense. It seems
> like Mongrel is intercepting the stdout + sterr (puts it all into
> mongrel.log), but it's not good to work with something that isn't
This probably begs some elaboration on just what puts() does. It
writes your string in one write operation, and does the newline in a
second operation, which opens the possibility that Ruby can make a
context switch between them. If the newline is already in the string,
though, it is just a single write operation. You can also use write()
instead of puts() to explicitly make sure that everything is done in a
single write call.
Take a look at the code in io.c for the details.
> Makes me wonder if the rails logs are safe if you write to them from
> different mongrels in a cluster. Any experience with this?
Even if it can be made "safe", contention from multiple processes
trying to write to one file can be a non-trivial performance hit.
This was one of my motivations for writing an async logger. I want
all of my app logs in the same place, even if I have multiple backend
processes, without worrying about resource contention. It's that, or
I have N log files, one for each backend process for my app.
More information about the Mongrel-users