[Mongrel] Mongrel and memory usage

Zed A. Shaw zedshaw at zedshaw.com
Wed Nov 7 12:01:33 EST 2007


On Tue, 6 Nov 2007 14:34:25 +1100
Dave Cheney <dave at cheney.net> wrote:

> Hi Kirk,
> 	
> 	I'm wondering if we're being hit by this issue in our application. We  
> generate a lot of thumbnails on the fly and use send_file to transfer  
> the data back to the browsers.
> 
> 	Checking the rails docks for send_file it indicates, that unless you  
> use the option :stream => false, the file will be read into a 4096  
> byte buffer and streamed to the client.
> 
> 	http://api.rubyonrails.com/classes/ActionController/Streaming.html#M000093
> 
> 	Is this a bug in send_file?

You souldn't use send_file at all really, because this streams the full file into a StringIO so that mongrel can then send the StringIO outside the rails lock, and because rails is inconsistent in how it sends headers and the body.

You should be using either x-sendfile or simply redirect to the real image.  If you need to auth the images then check out some of the auth-before-redirect modules available for various web servers.

-- 
Zed A. Shaw
- Hate: http://savingtheinternetwithhate.com/
- Good: http://www.zedshaw.com/
- Evil: http://yearofevil.com/


More information about the Mongrel-users mailing list