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

Jonathan Leighton turnip at turnipspatch.com
Thu Dec 21 17:15:20 EST 2006


I've had a right fun few days at work trying to figure out why our Rails
app (which isn't under very heavy load) kept eating memory and bringing
our server to our knees. Eventually I traced it to send_file (which was
in a way a relief as it wasn't down to my coding ;) -- every time a user
started downloading, the memory consumed by the app would jump, and
wouldn't go down again, even when they had cancelled the download (I
haven't tested whether the memory would still be consumed after they
completed the download). This has become apparent recently as the app
has been used for larger files (150MB and upwards). As a fix I've
delegated file serving to lighttpd + mod_sec_download, not quite as
convenient but probably better in the long run anyway.

So the problem is solved, but I was just wondering why this happened in
the first place; according to the Rails docs, send_file buffers the
response in order to not tie up memory. However, this was clearly not
happening -- is this possibly related to how Mongrel interacts with
Rails? If so, I gave it a try under lighttpd and still had the problem,
any idea why? I'm really just looking to understand the issue better as
I hate to walk away from a problem without fully comprehending it :)

Thanks,

-- 
Jonathan Leighton, Web Developer
Portfolio: http://jonathanleighton.com/
Personal: http://turnipspatch.com/



More information about the Mongrel-users mailing list