Apache consuming large amounts of memory

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
npietran
Posts: 7
Joined: Thu Aug 25, 2011 1:14 pm

Apache consuming large amounts of memory

Post by npietran »

The Apache server is consuming large amounts of memory and the processes consuming the memory have TCP connections from localhost. Has anyone seen this behavior before? Does anyone have any idea what may be causing it?

Thanks,

Nick P
mguthrie
Posts: 4380
Joined: Mon Jun 14, 2010 10:21 am

Re: Apache consuming large amounts of memory

Post by mguthrie »

Nagios XI uses AJAX requests to keep the data fresh in the interface without having to reload the pages. These settings can be adjusted and tweaked in the Admin->Performance Settings->Dashlets(tab). The amount of memory consumed is somewhat dependent on the environment size (quantity of hosts and services).
npietran
Posts: 7
Joined: Thu Aug 25, 2011 1:14 pm

Re: Apache consuming large amounts of memory

Post by npietran »

Here is a output from `top`. As you see the apache is consuming all of the memory resources. I would like to understand why the httpd is using so much memory.


top - 12:39:40 up 35 days, 1:17, 10 users, load average: 27.08, 15.84, 12.83
Tasks: 339 total, 1 running, 338 sleeping, 0 stopped, 0 zombie
Cpu(s): 13.4%us, 0.8%sy, 0.0%ni, 85.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
26654 apache 16 0 2703m 2.3g 4100 S 9.0 19.8 5:02.97 httpd
13705 apache 16 0 1034m 406m 4104 S 8.0 3.4 4:32.88 httpd
1768 apache 15 0 350m 76m 3692 S 6.0 0.6 0:14.60 httpd
3917 apache 16 0 1036m 705m 4092 S 6.0 5.9 3:48.62 httpd
1951 apache 16 0 317m 42m 3692 S 5.6 0.4 0:14.68 httpd
13738 apache 15 0 1405m 880m 4124 S 5.6 7.3 4:38.38 httpd
1590 apache 16 0 350m 76m 3692 S 5.0 0.6 0:14.59 httpd
2292 apache 15 0 494m 164m 3864 S 5.0 1.4 4:42.90 httpd
6164 apache 16 0 648m 321m 3920 S 5.0 2.7 4:37.94 httpd
12260 apache 16 0 651m 325m 4044 S 5.0 2.7 3:39.85 httpd
2036 apache 16 0 315m 42m 3660 S 4.6 0.4 0:12.02 httpd
25000 apache 16 0 2733m 404m 3876 S 4.6 3.4 4:30.45 httpd
27207 apache 16 0 616m 341m 3660 S 4.3 2.9 0:38.59 httpd
1769 apache 16 0 339m 65m 3660 S 4.0 0.5 0:14.07 httpd
27208 apache 16 0 685m 411m 3704 S 3.7 3.4 0:38.50 httpd
28834 apache 16 0 351m 78m 3672 S 3.0 0.7 0:25.06 httpd
2890 mysql 15 0 495m 47m 2464 S 1.3 0.4 247:45.79 mysqld
13740 apache 16 0 1456m 892m 4112 S 1.3 7.5 4:53.83 httpd
13707 apache 16 0 980m 649m 4072 S 1.0 5.4 4:17.38 httpd
13708 apache 17 0 608m 280m 4112 S 1.0 2.3 4:38.79 httpd
2349 postgres 15 0 119m 10m 9984 S 0.3 0.1 0:03.36 postmaster
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Apache consuming large amounts of memory

Post by lmiltchev »

It probably depends on your environment. In general, the memory your apache is using depends from php memory usage, from number of loaded apache and php modules and the number of connections.
Be sure to check out our Knowledgebase for helpful articles and solutions!
cloberjewels
Posts: 23
Joined: Wed Sep 21, 2011 10:59 am

Re: Apache consuming large amounts of memory

Post by cloberjewels »

We were originally running a standard/default php.ini and httpd.conf configuration.
We've adjusted our php.ini but we are still ending up with httpd processes that are holding ~1G of RAM:

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
27565 apache 16 0 1240m 912m 4148 S 0.0 7.6 8:41.37 httpd
20802 apache 16 0 1219m 892m 4088 S 0.0 7.4 8:27.20 httpd
20744 apache 25 0 1216m 888m 4132 S 0.0 7.4 9:32.63 httpd

It does not seem right that Apache should be holding onto this much memory.

When I run a pmap (pmap - report memory map of a process http://virtualthreads.blogspot.com/2006 ... linux.html)

# pmap -d 27565
27565: /usr/sbin/httpd
Address Kbytes Mode Offset Device Mapping
<snip>
00002b50cf3da000 52 r---- 0000000000000000 0fd:00008 en_GB.mo
00002b50cf3e7000 28 r--s- 0000000000000000 0fd:00007 gconv-modules.cache
00002b50d042b000 34756 rw--- 00002b50d042b000 000:00000 [ anon ]
00002b50d263b000 86636 rw--- 00002b50d263b000 000:00000 [ anon ]
00002b50d856c000 808596 rw--- 00002b50d856c000 000:00000 [ anon ]
00007fff9e069000 2632 rw--- 00007fffffd6c000 000:00000 [ stack ]
00007fff9e376000 16 r-x-- 00007fff9e376000 000:00000 [ anon ]
ffffffffff600000 8192 ----- 0000000000000000 000:00000 [ anon ]
mapped: 1278400K writeable/private: 935224K shared: 216K

You'll see that it is the heap is holding all the memory. So something allocated the memory but has not released it.

We also have KeepAlives turned off so connections are not remaining open to drive up memory usage.

This does not appear to be a configuration issue. Any other suggestions?
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Apache consuming large amounts of memory

Post by lmiltchev »

I am afraid I don't have an answer. However, I found a link that may at least give you some ideas; read the "Resolving: High Apache Memory Usage" section:

http://rimuhosting.com/howto/memory.jsp
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked