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

Jeremy Kemper jeremy at bitsweat.net
Thu Dec 21 22:09:33 EST 2006


On 12/21/06, Ezra Zygmuntowicz <ezmobius at gmail.com> wrote:
>
>         The rails send_file method is not the same thing as setting an X-
> SendFile header. If you are already using lighttpd for your server
> then your in good shape. THe rails send_file method actually does
> read the whole file into memory as it sends it to the client. SO you
> will see memory problems like you have if you use it on large files.
> The nice way to do it is to use the X-SendFile header in lighty. In a
> rails action that just wants to serve a static file from somewhere
> off the filesystem you can make it look like this:


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.

jeremy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20061221/bcb96031/attachment-0001.html 


More information about the Mongrel-users mailing list