# Nginx Issue

**URL:** <https://www.ruby-forum.com/t/nginx-issue/184561>\
**Category:** NGINX\
**Created:** [March 4, 2010, 1:59pm UTC](https://www.ruby-forum.com/t/nginx-issue/184561 "2010-03-04T13:59:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gmk.jaga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/aeb1de/32.png) [@gmk.jaga](https://www.ruby-forum.com/u/gmk.jaga)\
**Post date:** [March 4, 2010, 1:59pm UTC](https://www.ruby-forum.com/t/nginx-issue/184561/1 "2010-03-04T13:59:48Z")

</div>

My nginx is taking more memory. kindly advice me soon

```
                                                        By Thanks

```

Posted at Nginx Forum:

> **[Nginx Issue](https://forum.nginx.org/read.php?2,59889,59889#msg-59889)**
>
> My nginx is taking more memory. kindly advice me soon By Thanks

---

<div class="post-metadata">

**Author:** ![gmk.jaga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/aeb1de/32.png) [@gmk.jaga](https://www.ruby-forum.com/u/gmk.jaga)\
**Post date:** [March 4, 2010, 5:01pm UTC](https://www.ruby-forum.com/t/nginx-issue/184561/2 "2010-03-04T17:01:51Z")

</div>

On Thu, 2010-03-04 at 07:59 -0500, gmk.jaga wrote:

> My nginx is taking more memory. kindly advice me soon

> **[Be precise and informative about your problem - How To Ask Questions The Smart...](http://catb.org/~esr/faqs/smart-questions.html#beprecise)**
>
> Describe the symptoms of your problem or bug carefully and clearly.

Cliff

---

<div class="post-metadata">

**Author:** ![gmk.jaga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/aeb1de/32.png) [@gmk.jaga](https://www.ruby-forum.com/u/gmk.jaga)\
**Post date:** [March 5, 2010, 7:30pm UTC](https://www.ruby-forum.com/t/nginx-issue/184561/3 "2010-03-05T19:30:05Z")

</div>

On Fri, 2010-03-05 at 11:13 -0500, gmk.jaga wrote:

> Hi,
> 
> I am facing memory leak problem with nginx in my servers.
> 
> The nginx is taking more cache memory while running continuously.

“cache memory”? What command are you using to get this?

> ```
> proxy_max_temp_file_size 0;
> proxy_connect_timeout 30;
> 
> if (!-f $request_filename) {
> rewrite maintenance.html break;
> proxy_pass http://Sample;
> }
> }
> 
> ```

As an aside, it appears you could simplify your config a bit (and make  
it more efficient as well):

server {  
listen 80;  
client\_max\_body\_size 50M;  
server\_name [www.sample.com](http://www.sample.com);  
send\_timeout 20;

```
location / {
    root /home/public;
    expires 7d;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_max_temp_file_size 0;
    proxy_connect_timeout 30;

    try_files $uri $uri/ @backend;
}

location @backend {
    root /home/public;
    rewrite maintenance.html break;
    proxy_pass http://Sample;
}

```

}

Regards,  
Cliff

---

<div class="post-metadata">

**Author:** ![gmk.jaga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/aeb1de/32.png) [@gmk.jaga](https://www.ruby-forum.com/u/gmk.jaga)\
**Post date:** [March 12, 2010, 12:44pm UTC](https://www.ruby-forum.com/t/nginx-issue/184561/4 "2010-03-12T12:44:58Z")

</div>

We are getting the catch memory details from this cmd.

# free

Thanks.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,59889,63059#msg-63059](http://forum.nginx.org/read.php?2,59889,63059#msg-63059)

---

<div class="post-metadata">

**Author:** ![gmk.jaga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/aeb1de/32.png) [@gmk.jaga](https://www.ruby-forum.com/u/gmk.jaga)\
**Post date:** [March 5, 2010, 5:14pm UTC](https://www.ruby-forum.com/t/nginx-issue/184561/5 "2010-03-05T17:14:13Z")

</div>

Hi,

I am facing memory leak problem with nginx in my servers.

The nginx is taking more cache memory while running continuously.

I have hardly found any solutions to fix this memory leak problem.

Can any one please help me out in resolving this issue.

FYI - i have given my server nginx configuration and server detail below  
for references.

Thanks You!

Jaga

* * *

Server Configuration

Processor : 2x AMD Quad core 2382 @ 2.70Hz

Ram : 32GB memory

OS : CentOS release 5.3 (Final)

Nginx Version

nginx version: nginx/0.7.64  
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-46)  
configure arguments: --with-poll\_module --with-select\_module  
–with-rtsig\_module

Sample Configuration File

# user and group to run as

user root;

# number of nginx workers

worker\_processes 4;

# pid of nginx master process

pid /var/run/nginx.pid;

# Number of worker connections. 1024 is a good default

events {  
worker\_connections 4000;  
#use poll;  
multi\_accept on;  
accept\_mutex on;  
accept\_mutex\_delay 50ms;  
epoll\_events 1024;  
}

# start the http module where we config http access.

http {

# pull in mime-types. You can break out your config

# into as many include’s as you want to make it cleaner

include /usr/local/nginx/conf/mime.types;

# set a default type for the rare situation that

# nothing matches from the mimie-type include

default\_type application/octet-stream;

# configure log format

log\_format main '“Status” $status “Bytes” $bytes\_sent “u Addr:”  
$upstream\_addr “u status” $upstream\_status “U Response”  
$upstream\_response\_time “MSec” $msec ';

log\_format error '“Status” $status “Bytes” $bytes\_sent “u Addr:”  
$upstream\_addr “u status” $upstream\_status “U Response”  
$upstream\_response\_time “MSec” $msec ';

# main access log

#access\_log /var/log/nginx/nginx\_access.log main;  
access\_log off;

# main error log

error\_log /var/log/nginx/nginx\_error.log error;

# no sendfile on OSX

sendfile on;  
keepalive\_timeout 5;

# These are good default values.

tcp\_nopush on;  
tcp\_nodelay on;

# output compression saves bandwidth

gzip off;

client\_body\_timeout 1s;

upstream Sample {

```
server 127.0.0.1:9000 weight=3;
server 127.0.0.1:9001 weight=3;
server 127.0.0.1:9002 weight=3;
server 127.0.0.1:9003 weight=3;
server 127.0.0.1:9004 weight=3;

server 192.168.1.2:9000 weight=3;
server 192.168.1.2:9001 weight=3;
server 192.168.1.2:9002 weight=3;
server 192.168.1.2:9003 weight=3;
server 192.168.1.2:9004 weight=3;

server 192.168.1.3:9000 weight=3;
server 192.168.1.3:9001 weight=3;
server 192.168.1.3:9002 weight=3;
server 192.168.1.3:9003 weight=3;
server 192.168.1.3:9004 weight=3;

server 192.168.1.4:9000 weight=3;
server 192.168.1.4:9001 weight=3;
server 192.168.1.4:9002 weight=3;
server 192.168.1.4:9003 weight=3;
server 192.168.1.4:9004 weight=3;

```

}

server {

```
listen 80;

client_max_body_size 50M;

server_name www.sample.com;

root /home/public;

# access_log /var/log/nginx.vhost.access.log main;
send_timeout 20;

location ~* 

```

^.+.(jpg|jpeg|JPG|JPEG|GIF|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$  
{  
root /home/public;  
expires 7d;

```
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_max_temp_file_size 0;
    proxy_connect_timeout 30;

    if (!-f $request_filename) {
rewrite maintenance.html break;
      proxy_pass http://Sample;
    }
}

```

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,59889,60377#msg-60377](http://forum.nginx.org/read.php?2,59889,60377#msg-60377)

---

<div class="post-metadata">

**Author:** ![gmk.jaga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/aeb1de/32.png) [@gmk.jaga](https://www.ruby-forum.com/u/gmk.jaga)\
**Post date:** [March 12, 2010, 1:28pm UTC](https://www.ruby-forum.com/t/nginx-issue/184561/6 "2010-03-12T13:28:51Z")

</div>

Hello!

On Fri, Mar 12, 2010 at 06:44:03AM -0500, gmk.jaga wrote:

> We are getting the catch memory details from this cmd.
> 
> # free

Amount of memory reported in “cached” column by free corresponds  
to memory used for page cache, i.e. cache memory used for files  
read from disk.

As long as you have [at least some] free memory - it is normal  
that cached will grow. Any free memory available in system will  
be used by your OS to cache files.

Maxim D.
