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 11 Sep '11, 12:15
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),
And you can see total processes with RAM use in bytes with this command,
We have a memory monitor script here that can be set up in conjunction with crontab to give you status over time,
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 11 Sep '11, 17:14
Thanks for the response I ran the command ps -u user -o rss,command:
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