login community faq

I'm having a problem with my custom NGINX install and the single ruby on rails app I'm hosting with it. At certain times it seems to take up almost twice my available RAM/Memory and then the process gets terminated which shuts the site down.

Is there anything I can do to reduce it's memory consumption? I checked and it's running in the production environment so it's at least not that simple.

I'm really stumped and my client is getting upset and I'm just not sure how to fix this.

asked Sep 11 '11 at 12:15

Jaybydesign's gravatar image

Jaybydesign
266


We need some more info to be able to assist you. Typically nginx/passenger/ruby apps do not occupy that much memory. However like any dynamic application it is subject to change, and it greatly depends on what logic your site is processing, how much traffic, and various other variables.

One thing we would need to know is exactly how much RAM does your application use? Does this use stay steady most of the time? How long/gradually does it take for the memory to increase, does it normally stay low and than happen in 1 large 'spike' or is it a gradual buildup of RAM over time/requests?

You can see how much RAM you are using in MBs with this command (replace 'user' with your username),

1
ps -u user -o rss,command | grep -v peruser | awk '{sum+=$1} END {print sum/1024}'

And you can see total processes with RAM use in bytes with this command,

1
ps -u user -o rss,command

We have a memory monitor script here that can be set up in conjunction with crontab to give you status over time,

1
https://wiki.webfaction.com/attachment/wiki/MiscellaneousFiles/memory_usage.py

Once you know what the memory 'leak' looks like you can than try to determine why. By comparing the stats to your request logs you should be able to see what the site was doing at that time and possibly reproduce the issue. Once you have isolated the 'leak' you can debug that part of your code.

answered Sep 11 '11 at 17:14

johns's gravatar image

johns ♦♦
345427

Thanks for the response I ran the command ps -u user -o rss,command:

RSS COMMAND

1604 sshd: ********@pts/16

2284 -bash

1572 PassengerWatchdog

2640 PassengerHelperAgent

7188 Passenger spawn server

2592 PassengerLoggingAgent

792 nginx: master process /home/********/webapps/nginx/nginx/sbin/nginx -p /home/********/webapps/nginx/

1696 nginx: worker process

43704 Passenger ApplicationSpawner: /home/********/webapps/nginx/pierce_engineering

49544 Rack: /home/********/webapps/nginx/pierce_engineering

2900 vim nginx.conf

41200 Rack: /home/********/webapps/nginx/pierce_engineering

908 ps -u ******** -o rss,command

1624 sshd: ********@pts/2

2312 -bash

So Rack is using 49 mb, Passenger 43mb and another rack is using 41 mb totaling to 133 mb. Which doesn't seem right on many counts. My app shouldn't be using that much memory at all, it's just a basic product based site the only time it uses a database is when retrieving product data to load on the page then that's it.

In-fact here it is: http://pierceengineeringltd.com

answered Sep 11 '11 at 22:28

Jaybydesign's gravatar image

Jaybydesign
266

edited Sep 11 '11 at 22:32

Looking at the account directly I do not see anything obvious, but I did not dig into the code itself. I did notice your memory was between 74MB and 114MB while I was researching. And that after running passenger-status on the main thread it dropped,

[you@webX ~]$ ./.rvm/gems/ree-1.8.7-2011.03/bin/passenger-status 10824

http://modrails.com/documentation/Users%20guide%20Nginx.html#_inspecting_memory_usage

You might want to look into different caching methods for Rack, http://rtomayko.github.com/rack-cache/storage

(Sep 11 '11 at 23:47) johns ♦♦ johns's gravatar image

Hmm I'm not sure how accurate that data is because I'm not using the Ruby Enterprise Edition I just switched it recently to try setting up REE as it reduces memory apparently. However I forgot how to setup phusion passenger with it so I'll have to try and remember on my development machine and repeat those steps on the production server.

Anyway I'll check out that rack cache and see if I can reduce some memory consumption with that. Thanks for your help, I really appreciate it.

(Sep 12 '11 at 00:13) Jaybydesign Jaybydesign's gravatar image

You're welcome.

(Sep 12 '11 at 00:31) johns ♦♦ johns's gravatar image
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×129
×79
×58
×7
×4

Asked: Sep 11 '11 at 12:15

Seen: 2,067 times

Last updated: Sep 12 '11 at 00:31

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited