# Nginx eating all RAM, log files?

**URL:** <https://www.ruby-forum.com/t/nginx-eating-all-ram-log-files/228438>\
**Category:** NGINX\
**Created:** [April 22, 2013, 8:31pm UTC](https://www.ruby-forum.com/t/nginx-eating-all-ram-log-files/228438 "2013-04-22T20:31:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jchengj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jchengj](https://www.ruby-forum.com/u/jchengj)\
**Post date:** [April 22, 2013, 8:31pm UTC](https://www.ruby-forum.com/t/nginx-eating-all-ram-log-files/228438/1 "2013-04-22T20:31:14Z")

</div>

I have two nginx instances (nginx/1.0.15) on a 4GB RAM machine. Each  
instance runs fewer than 25 requests as reported with stub\_status on;

The problem is that once nginx is started from scratch it starts eating  
(or reserving?) RAM progressively as reported by free -m, up to the  
point where it leaves only 2-5mb left and then it doesnt go past that.  
In about 7 days it has eating everything. Nginx doesnt crash, nor does  
it touch swap but I definately feel it  
compromises system resources to the point iam concerned as in a  
production spike its wise to think the server has no room.

This is the exact same issue on 4 other nginx machines I have.

In order to start over again I must kill -QUIT the PIDs , delete the log  
file (which is smaller then 800mb) and then all goes back to the cycle.

Please indicate me what pieces of information I can supply to debug this  
issue.

Thanks  
Joseph

---

<div class="post-metadata">

**Author:** ![jchengj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jchengj](https://www.ruby-forum.com/u/jchengj)\
**Post date:** [April 22, 2013, 8:46pm UTC](https://www.ruby-forum.com/t/nginx-eating-all-ram-log-files/228438/2 "2013-04-22T20:46:26Z")

</div>

Before anything I suggest you upgrade you nginx install… you’re  
running  
nginx/1.0.15, the last satble version is 1.2.8!

It might be some bug that was fixing in the mean time!

---

<div class="post-metadata">

**Author:** ![jchengj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jchengj](https://www.ruby-forum.com/u/jchengj)\
**Post date:** [April 22, 2013, 9:33pm UTC](https://www.ruby-forum.com/t/nginx-eating-all-ram-log-files/228438/3 "2013-04-22T21:33:10Z")

</div>

Hi  
Are you sure it’s not the linux file/buffer cache that’s using all your  
ram? (does ps/top show nginx or the worker processes using it directly?)  
Linux and most/all other unix variants will fill up unused ram with  
cached versions of the most recently used files so they don’t have to be  
read from disk each time… it’s completely normal and expected  
behaviour 🙂

---

<div class="post-metadata">

**Author:** ![jchengj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jchengj](https://www.ruby-forum.com/u/jchengj)\
**Post date:** [April 22, 2013, 10:04pm UTC](https://www.ruby-forum.com/t/nginx-eating-all-ram-log-files/228438/4 "2013-04-22T22:04:43Z")

</div>

Hello!,

This is the output of ps, iam having a hard time interpreting the memory  
usage perhaps you can help me differ?

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND  
root 18951 0.0 0.1 195892 6340 ? Ss Apr16 0:00 nginx:  
master process /usr/sbin/nginx -c  
/etc/nginx/modified/nginx-consolidated-5.conf  
root 18977 0.0 0.1 197600 5188 ? Ss Apr16 0:00 nginx:  
master process /usr/sbin/nginx -c  
/etc/nginx/modified/nginx-consolidated-8.conf  
nginx 18978 0.0 0.2 200096 9392 ? S Apr16 5:02 nginx:  
worker process  
nginx 18979 0.0 0.1 197604 5768 ? S Apr16 0:03 nginx:  
cache manager process  
nginx 23921 0.0 0.2 199892 9148 ? S Apr21 1:28 nginx:  
worker process  
nginx 23922 0.0 0.1 195896 4844 ? S Apr21 0:00 nginx:  
cache manager process  
root 24894 0.0 0.0 103244 832 pts/0 S+ 14:00 0:00 grep  
nginx  
[root]# free -m  
total used free shared buffers  
cached  
Mem: 3631 1760 1871 0 307  
1212  
-/+ buffers/cache: 240 3391  
Swap: 2047 0 2047

I have a cache explicitly set at the nginx.conf . My site is not that  
big, the cache I have doesnt get pass 15mb.

Please let me know if this is suitable or if I should report  
differently.

Thanks  
Joseph

Date: Mon, 22 Apr 2013 20:32:31 +0100  
From: removed\_email\_address@domain.invalid  
To: removed\_email\_address@domain.invalid  
Subject: Re: nginx eating all RAM, log files?

```
Hi

Are you sure it's not the linux file/buffer cache that's using all
your ram? (does ps/top show nginx or the worker processes using it
directly?)

Linux and most/all other unix variants will fill up unused ram with
cached versions of the most recently used files so they don't have
to be read from disk each time... it's completely normal and
expected behaviour :)

On 22/04/13 19:30, Joseph C.
  wrote:

  I have two nginx instances (nginx/1.0.15) on a 4GB
    RAM machine. Each instance runs fewer than 25 requests as
    reported with stub_status on;

    The problem is that once nginx is started from scratch it starts
    eating (or reserving?) RAM progressively as reported by free -m,
    up to the point where it leaves only 2-5mb left and then it
    doesnt go past that. In about 7 days it has eating everything.
    Nginx doesnt crash, nor does it touch swap but I definately feel
    it compromises system resources to the point iam concerned as in
    a production spike its wise to think the server has no room.

    This is the exact same issue on 4 other nginx machines I have.

    In order to start over again I must kill -QUIT the PIDs , delete
    the log file (which is smaller then 800mb) and then all goes
    back to the cycle.

    Please indicate me what pieces of information I can supply to
    debug this issue.

    Thanks

    Joseph

  _______________________________________________

```

nginx mailing list  
removed\_email\_address@domain.invalid  
[http://mailman.nginx.org/mailman/listinfo/nginx](http://mailman.nginx.org/mailman/listinfo/nginx)

---

<div class="post-metadata">

**Author:** ![jchengj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jchengj](https://www.ruby-forum.com/u/jchengj)\
**Post date:** [April 22, 2013, 10:08pm UTC](https://www.ruby-forum.com/t/nginx-eating-all-ram-log-files/228438/5 "2013-04-22T22:08:13Z")

</div>

Maxim,

Thank you…!!

Regards,  
Josephan/listinfo/nginx

---

<div class="post-metadata">

**Author:** ![jchengj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jchengj](https://www.ruby-forum.com/u/jchengj)\
**Post date:** [April 22, 2013, 10:29pm UTC](https://www.ruby-forum.com/t/nginx-eating-all-ram-log-files/228438/6 "2013-04-22T22:29:51Z")

</div>

man ps | grep RSS  
man ps | grep VSZ

when using a tool like top: real\_free = free + cached

you might want to try htop for a better continuous display

your ram is fine 🙂

regards,

mex

Posted at Nginx Forum:

> **[Re: RE: nginx eating all RAM, log files?](https://forum.nginx.org/read.php?2,238547,238556#msg-238556)**
>
> I have two nginx instances (nginx/1.0.15) on a 4GB RAM machine. Each instance runs fewer than 25 requests as reported with stub\_status on; The problem is that once nginx is started from scratch it starts eating (or reserving?) RAM progressively as...

---

<div class="post-metadata">

**Author:** ![jchengj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d78d45/32.png) [@jchengj](https://www.ruby-forum.com/u/jchengj)\
**Post date:** [April 22, 2013, 9:33pm UTC](https://www.ruby-forum.com/t/nginx-eating-all-ram-log-files/228438/7 "2013-04-22T21:33:45Z")

</div>

Hello!

On Mon, Apr 22, 2013 at 06:30:41PM +0000, Joseph C. wrote:

> a production spike its wise to think the server has no room.
> 
> This is the exact same issue on 4 other nginx machines I have.
> 
> In order to start over again I must kill -QUIT the PIDs , delete  
> the log file (which is smaller then 800mb) and then all goes  
> back to the cycle.
> 
> Please indicate me what pieces of information I can supply to  
> debug this issue.

As you are referring to “free -m” output, most likely this link  
will help:

[http://www.linuxatemyram.com/](http://www.linuxatemyram.com/)

In short: don’t panic, you RAM is fine.

–  
Maxim D.  
[http://nginx.org/en/donation.html](http://nginx.org/en/donation.html)
