Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

thin eats all memory when requesting a large static file

#80

If requesting a large (over 600MB) static file, thin eats a lot of memory, here are some hints:

rolando@prod01:/var/www/spawner/sites/scio.cl$ ps -fu rolando
UID        PID  PPID  C STIME TTY          TIME CMD
rolando  20951 20948  0 12:08 ?        00:00:00 sshd: rolando@pts/1
rolando  20952 20951  0 12:08 pts/1    00:00:00 -bash
rolando  21038     1  6 12:15 ?        00:00:00 thin server (0.0.0.0:3000)                                                                     
rolando@prod01:/var/www/spawner/sites/scio.cl$ ps -opid,rss,cmd -u rolando
  PID   RSS CMD
20951   664 sshd: rolando@pts/1
20952  1524 -bash
21038 14848 thin server (0.0.0.0:3000)                                                                                                         
21043   876 ps -opid,rss,cmd -u rolando
# here I request a large static file
rolando@prod01:/var/www/spawner/sites/scio.cl$ ps -opid,rss,cmd -u rolando
  PID   RSS CMD
20951   664 sshd: rolando@pts/1
20952  1524 -bash
21038 166284 thin server (0.0.0.0:3000)                                                                                                        
21044   872 ps -opid,rss,cmd -u rolando
rolando@prod01:/var/www/spawner/sites/scio.cl$ ps -opid,rss,cmd -u rolando
  PID   RSS CMD
20951   664 sshd: rolando@pts/1
20952  1524 -bash
21038 291064 thin server (0.0.0.0:3000)                                                                                                        
21045   876 ps -opid,rss,cmd -u rolando
rolando@prod01:/var/www/spawner/sites/scio.cl$ ps -opid,rss,cmd -u rolando
  PID   RSS CMD
20951   664 sshd: rolando@pts/1
20952  1524 -bash
21038 310892 thin server (0.0.0.0:3000)                                                                                                        
21046   876 ps -opid,rss,cmd -u rolando
rolando@prod01:/var/www/spawner/sites/scio.cl$ ps -opid,rss,cmd -u rolando
  PID   RSS CMD
20951   664 sshd: rolando@pts/1
20952  1520 -bash
21038 399180 thin server (0.0.0.0:3000)                                                                                                        
21047   876 ps -opid,rss,cmd -u rolando
# had to kill it the hard way
rolando@prod01:/var/www/spawner/sites/scio.cl$ kill -9 21038
rolando@prod01:/var/www/spawner/sites/scio.cl$ ps -opid,rss,cmd -u rolando
  PID   RSS CMD
20951   664 sshd: rolando@pts/1
20952  1516 -bash
21048   876 ps -opid,rss,cmd -u rolando

Reported by rolando · September 1st, 2008 @ 10:23 PM

State: invalid
Milestone: Future
Assigned to: macournoyer macournoyer

Activity

  1. macournoyer
    macournoyer
    • State changed from new to open
    • Tag set to memory

    hey Rolando,

    This all depends on how you send the file in the code. Are you using Rails? Can you paste the code that sends the file.

    Also tell me which version of Thin you are using (thin -v).

    Thx for reporting!

    September 1st, 2008 @ 10:27 PM

  2. macournoyer
    macournoyer

    I know this is how it's done in the adapter, but that is just for development. Serving static file should be done by a "real" web server like apache or nginx.

    Or if you really want to do it in Ruby you should use streaming.

    September 5th, 2008 @ 09:16 AM

  3. macournoyer
    macournoyer

    You can use the X-Sendfile header to process the request in Ruby but send the file using lighty:

    http://blog.lighttpd.net/article...

    September 5th, 2008 @ 10:14 AM

  4. macournoyer
    macournoyer
    • State changed from open to invalid

    September 28th, 2008 @ 02:46 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.