thin eats all memory when requesting a large static file
Reported by rolando | 2008-09-01 22:23:33 UTC | in Future
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
Comments and changes to this ticket
-

macournoyer 2008-09-01 22:27:52 UTC
- 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!
-

macournoyer 2008-09-05 09:16:37 UTC
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.
-

macournoyer 2008-09-05 10:14:21 UTC
You can use the X-Sendfile header to process the request in Ruby but send the file using lighty:
-

macournoyer 2008-09-28 14:46:51 UTC
- State changed from open to invalid
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป