apache eats up too much ram per child

Posted by mrc4r7m4n on Server Fault See other posts from Server Fault or by mrc4r7m4n
Published on 2010-05-20T08:20:18Z Indexed on 2010/05/21 9:51 UTC
Read the original article Hit count: 1176

Filed under:
|

Hello to everyone.

I've got fallowing problem: Apache eat to many ram per child.

The fallowing comments shows:

  1. cat /etc/redhat-release -- Fedora release 8 (Werewolf)

  2. free -m:

             total       used       free     shared    buffers     cached
Mem:          3566       3136        429          0        339       1907
-/+ buffers/cache:        889       2676
Swap:         4322          0       4322

I know that you will say that there is nothing to worry about because swap is not use, but i think it's not use for now.

3.httpd -v:

Server version: Apache/2.2.14 (Unix)

4.httpd -l:

Compiled in modules:

core.c

mod_authn_file.c

mod_authn_default.c

mod_authz_host.c

mod_authz_groupfile.c

mod_authz_user.c

mod_authz_default.c

mod_auth_basic.c

mod_include.c

mod_filter.c

mod_log_config.c

mod_env.c

mod_setenvif.c

mod_version.c

mod_ssl.c

prefork.c

http_core.c

mod_mime.c

mod_status.c

mod_autoindex.c

mod_asis.c

mod_cgi.c

mod_negotiation.c

mod_dir.c

mod_actions.c

mod_userdir.c

mod_alias.c

mod_rewrite.c

mod_so.c

5.List of loaded dynamic modules:

LoadModule authz_host_module

modules/mod_authz_host.so LoadModule

include_module modules/mod_include.so

LoadModule log_config_module

modules/mod_log_config.so LoadModule

setenvif_module

modules/mod_setenvif.so LoadModule

mime_module modules/mod_mime.so

LoadModule autoindex_module

modules/mod_autoindex.so LoadModule

vhost_alias_module modules/mod_vhost_alias.so LoadModule

negotiation_module

modules/mod_negotiation.so LoadModule

dir_module modules/mod_dir.so

LoadModule alias_module

modules/mod_alias.so LoadModule

rewrite_module modules/mod_rewrite.so

LoadModule proxy_module

modules/mod_proxy.so LoadModule

cgi_module modules/mod_cgi.so

6.My prefrok directive

<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   25
ServerLimit       80
MaxClients        80
MaxRequestsPerChild  4000
</IfModule>

KeepAliveTimeout 6
MaxKeepAliveRequests 100
KeepAlive On

7.top -u apache: ctrl+ M

top - 09:19:42 up 2 days, 19 min,  2 users,  load average: 0.85, 0.87, 0.80
Tasks: 113 total,   1 running, 112 sleeping,   0 stopped,   0 zombie
Cpu(s):  7.3%us, 15.7%sy,  0.0%ni, 75.7%id,  0.0%wa,  0.7%hi,  0.7%si,  0.0%st
Mem:   3652120k total,  3149964k used,   502156k free,   348048k buffers
Swap:  4425896k total,        0k used,  4425896k free,  1944952k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
16956 apache    20   0  700m 135m 100m S  0.0  3.8   2:16.78 httpd
16953 apache    20   0  565m 130m  96m S  0.0  3.7   1:57.26 httpd
16957 apache    20   0  587m 129m 102m S  0.0  3.6   1:47.41 httpd
16955 apache    20   0  567m 126m  93m S  0.0  3.6   1:43.60 httpd
17494 apache    20   0  626m 125m  96m S  0.0  3.5   1:58.77 httpd
17515 apache    20   0  540m 120m  88m S  0.0  3.4   1:45.57 httpd
17516 apache    20   0  573m 120m  88m S  0.0  3.4   1:50.51 httpd
16954 apache    20   0  551m 120m  88m S  0.0  3.4   1:52.47 httpd
17493 apache    20   0  586m 120m  94m S  0.0  3.4   1:51.02 httpd
17279 apache    20   0  568m 117m  87m S 16.0  3.3   1:51.87 httpd
17302 apache    20   0  560m 116m  90m S  0.3  3.3   1:59.06 httpd
17495 apache    20   0  551m 116m  89m S  0.0  3.3   1:47.51 httpd
17277 apache    20   0  476m 114m  81m S  0.0  3.2   1:37.14 httpd
30097 apache    20   0  536m 113m  83m S  0.0  3.2   1:47.38 httpd
30112 apache    20   0  530m 112m  81m S  0.0  3.2   1:40.15 httpd
17513 apache    20   0  516m 112m  85m S  0.0  3.1   1:43.92 httpd
16958 apache    20   0  554m 111m  82m S  0.0  3.1   1:44.18 httpd
 1617 apache    20   0  487m 111m  85m S  0.0  3.1   1:31.67 httpd
16952 apache    20   0  461m 107m  75m S  0.0  3.0   1:13.71 httpd
16951 apache    20   0  462m 103m  76m S  0.0  2.9   1:28.05 httpd
17278 apache    20   0  497m 103m  76m S  0.0  2.9   1:31.25 httpd
17403 apache    20   0  537m 102m  79m S  0.0  2.9   1:52.24 httpd
25081 apache    20   0  412m 101m  70m S  0.0  2.8   1:01.74 httpd

I guess thats all information needed to help me solve this problem. I think the virt memory is to big, the same res. The consumption of ram is increasing all the time. Maybe it's memory leak because i see there is so many static modules compiled.

Could someone help me with this issue? Thank you in advance.

8.ldd /usr/sbin/httpd

linux-gate.so.1 =>  (0x0012d000)
libm.so.6 => /lib/libm.so.6 (0x0012e000)
libpcre.so.0 => /lib/libpcre.so.0 (0x00157000)
libselinux.so.1 => /lib/libselinux.so.1 (0x0017f000)
libaprutil-1.so.0 => /usr/lib/libaprutil-1.so.0 (0x0019a000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x001b4000)
libldap-2.3.so.0 => /usr/lib/libldap-2.3.so.0 (0x001e6000)
liblber-2.3.so.0 => /usr/lib/liblber-2.3.so.0 (0x00220000)
libdb-4.6.so => /lib/libdb-4.6.so (0x0022e000)
libexpat.so.1 => /lib/libexpat.so.1 (0x00370000)
libapr-1.so.0 => /usr/lib/libapr-1.so.0 (0x00391000)
libpthread.so.0 => /lib/libpthread.so.0 (0x003b9000)
libdl.so.2 => /lib/libdl.so.2 (0x003d2000)
libc.so.6 => /lib/libc.so.6 (0x003d7000)
/lib/ld-linux.so.2 (0x00110000)
libuuid.so.1 => /lib/libuuid.so.1 (0x00530000)
libresolv.so.2 => /lib/libresolv.so.2 (0x00534000)
libsasl2.so.2 => /usr/lib/libsasl2.so.2 (0x00548000)
libssl.so.6 => /lib/libssl.so.6 (0x00561000)
libcrypto.so.6 => /lib/libcrypto.so.6 (0x005a6000)
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2 (0x006d9000)
libkrb5.so.3 => /usr/lib/libkrb5.so.3 (0x00707000)
libcom_err.so.2 => /lib/libcom_err.so.2 (0x0079a000)
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3 (0x0079d000)
libz.so.1 => /lib/libz.so.1 (0x007c3000)
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0 (0x007d6000)
libkeyutils.so.1 => /lib/libkeyutils.so.1 (0x007df000)

Currently i cant restart the apache. I work in a company and now there is rush hours. I will do that about 5 pm.

Current top -u apache: shift + M

top - 12:31:33 up 2 days,  3:30,  1 user,  load average: 0.73, 0.80, 0.79
Tasks: 114 total,   1 running, 113 sleeping,   0 stopped,   0 zombie
Cpu(s):  3.3%us,  4.7%sy,  0.0%ni, 90.0%id,  1.3%wa,  0.3%hi,  0.3%si,  0.0%st
Mem:   3652120k total,  3169720k used,   482400k free,   353372k buffers
Swap:  4425896k total,        0k used,  4425896k free,  1978688k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
16957 apache    20   0  708m 145m 117m S  0.0  4.1   2:11.32 httpd
16956 apache    20   0  754m 142m 107m S  0.0  4.0   2:33.94 httpd
16955 apache    20   0  641m 136m 103m S  5.3  3.8   1:58.37 httpd
17515 apache    20   0  624m 131m  99m S  0.0  3.7   2:03.90 httpd
16954 apache    20   0  627m 130m  98m S  0.0  3.6   2:13.87 httpd
17302 apache    20   0  625m 124m  97m S  0.0  3.5   2:10.80 httpd
17403 apache    20   0  624m 114m  91m S  0.0  3.2   2:08.85 httpd
16952 apache    20   0  502m 114m  81m S  0.0  3.2   1:23.78 httpd
16186 apache    20   0  138m  61m  35m S  0.0  1.7   0:15.54 httpd
16169 apache    20   0  111m  49m  17m S  0.0  1.4   0:06.00 httpd
16190 apache    20   0  126m  48m  24m S  0.0  1.4   0:11.44 httpd
16191 apache    20   0  109m  48m  19m S  0.0  1.4   0:04.62 httpd
16163 apache    20   0  114m  48m  21m S  0.0  1.4   0:09.60 httpd
16183 apache    20   0  127m  48m  23m S  0.0  1.3   0:11.23 httpd
16189 apache    20   0  109m  47m  17m S  0.0  1.3   0:04.55 httpd
16201 apache    20   0  106m  47m  17m S  0.0  1.3   0:03.90 httpd
16193 apache    20   0  103m  46m  20m S  0.0  1.3   0:10.76 httpd
16188 apache    20   0  107m  45m  18m S  0.0  1.3   0:04.85 httpd
16168 apache    20   0  103m  44m  17m S  0.0  1.2   0:05.61 httpd
16187 apache    20   0  118m  41m  21m S  0.0  1.2   0:08.50 httpd
16184 apache    20   0  111m  41m  19m S  0.0  1.2   0:09.28 httpd
16206 apache    20   0  110m  41m  20m S  0.0  1.2   0:11.69 httpd
16199 apache    20   0  108m  40m  17m S  0.0  1.1   0:07.76 httpd
16166 apache    20   0  104m  37m  18m S  0.0  1.0   0:04.31 httpd
16185 apache    20   0 99.3m  36m  16m S  0.0  1.0   0:04.16 httpd

as you can see the memory usage growing up from e.g. res( 135 to 145)m and it will be growing up till memory ends. Are you sure that this option i set up:

<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   25
ServerLimit       80
MaxClients        80
MaxRequestsPerChild  4000
</IfModule>

KeepAliveTimeout 6
MaxKeepAliveRequests 100
KeepAlive On

are correct? Maybe i should decrease some of them?

Another questions that bother me: I got e.g. static module mod_negotiation.c compiled into apache and the same module loaded as dynamic. Is this normal that i've loaded duplicated module. But when i want to remove dynamic module(mod_negotiation.c) from httpd.conf and then restart apache error appears. Now I cant tell this error message because i cant restart apache :(


Hello again:) This is memory usage just after restart apache:

top - 16:19:12 up 2 days,  7:18,  3 users,  load average: 1.08, 0.91, 0.91
Tasks: 109 total,   2 running, 107 sleeping,   0 stopped,   0 zombie
Cpu(s): 17.0%us, 25.7%sy, 51.0%ni,  4.7%id,  0.0%wa,  0.3%hi,  1.3%si,  0.0%st
Mem:   3652120k total,  2762516k used,   889604k free,   361552k buffers
Swap:  4425896k total,        0k used,  4425896k free,  2020980k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
13569 apache    20   0 93416  43m  15m S  0.0  1.2   0:02.55 httpd
13575 apache    20   0 98356  38m  16m S 32.3  1.1   0:02.55 httpd
13571 apache    20   0 86808  33m  12m S  0.0  0.9   0:02.60 httpd
13568 apache    20   0 86760  33m  12m S  0.0  0.9   0:00.81 httpd
13570 apache    20   0 83480  33m  12m S  0.0  0.9   0:00.51 httpd
13572 apache    20   0 63520 5916 1548 S  0.0  0.2   0:00.02 httpd
13573 apache    20   0 63520 5916 1548 S  0.0  0.2   0:00.02 httpd
13574 apache    20   0 63520 5916 1548 S  0.0  0.2   0:00.02 httpd
13761 apache    20   0 63388 5128  860 S  0.0  0.1   0:00.01 httpd
13762 apache    20   0 63388 5128  860 S  0.0  0.1   0:00.01 httpd
13763 apache    20   0 63388 5128  860 S  0.0  0.1   0:00.00 httpd

I will try to compile apache from source to newest version. Thx for help guys.

© Server Fault or respective owner

Related posts about apache

Related posts about memory-usage