[Mongrel] Rails' send_file, Mongrel, and *gasp* memory

Jonathan Leighton turnip at turnipspatch.com
Fri Dec 22 03:57:16 EST 2006


On Fri, 2006-12-22 at 00:06 -0800, Zed A. Shaw wrote:
> > To be clear, send_file does not read the whole file into memory -- it blows
> > chunks into the output stream. Mongrel and pure-Ruby FastCGI use StringIO to
> > buffer the response before sending it to the client.
> > 
> > X-Sendfile is definitely the way to go in any case.
> 
> Just to be extra clear, neither of the two main systems for hosting Rails would need to buffer the output if Rails didn't alternate between sending headers and body content.
> 
> And yes, X-Sendfile is the way to go.

Thanks for all your responses. Just in case it makes a difference, I'll
clarify about my setup. Basically we have an Apache on port 80 which
can't be removed from the equation. The Rails app is served directly
Apache -> Mongrel, and now I have made it so the /file/ path is proxied
Apache -> lighttpd, which serves the files using mod_secdownload. I
wasn't actually aware of X-Sendfile so that's interesting -- is this
better, worse or equal to using mod_secdownload? I wouldn't have thought
it made a difference as they both enable lighttpd to serve the static
files, but if people think I should drop the mod_secdownload solution in
favour of X-Sendfile I guess I could set up the application to go
through lighttpd too.

Thanks again,

Jon



More information about the Mongrel-users mailing list