Huge apache memory consumption

18 posts / 0 new
Last post
#1 Mon, 08/29/2011 - 23:31
carloxp

Huge apache memory consumption

Hello today I've noted that every apache process takes around 417,688 kB of memory. Furthermore, it seems that other processes take too memory too.

(Please, look at attached snapshot)

It is normal?

Thank you Carlo

Mon, 08/29/2011 - 23:39
andreychek

Howdy,

Well, I don't see your screenshot, but I can take a few guesses.

First, is your system a 64-bit system? A 64-bit system will use roughly twice the RAM as it's 32-bit counter parts.

Second, that may mean you have a lot of modules loaded. You may want to disable Apache modules that you don't need.

If you're loading mod_php, then that memory also includes the PHP modules you're loading.

So, you may be able to reduce your memory usage by disabling Apache modules and PHP modules that you don't need.

-Eric

Mon, 08/29/2011 - 23:55
carloxp

Hello!

Yes, it is CentOS 5.6 64bit.

I only loaded modules needed by PHP, without adding additional apache modules.

I try to attach snapshot again...

Tue, 08/30/2011 - 08:56
andreychek

Howdy,

Since your OS is 64 bit, that means that all processes will take up roughly double the memory as you'd see on a 32 bit system. So that's part of the issue there.

Looking at your processes, the PHP apps running on your system are taking 220MB to 290MB. That could just be the memory requirements of the apps you're running, or it could mean the number of PHP modules being loaded are taking up a bunch of memory.

That also means that if you're loading the mod_php Apache module, that a decent amount of the RAM you're seeing in use may be due to that; you might want to disable mod_php to see how much RAM that frees up.

What is the output of this command:

rpm -qa | grep php-

Tue, 12/13/2011 - 19:28 (Reply to #4)
vectorsites

I too have this same issue but the 64 bit system is the same before atomic upgrade and now memory is through the roof and also sometimes maxing out. Seems mostly Apache and lots of php-cgi instances. I am running Centos5 on 64 bit Openvz system.

rpm -qa | grep php-

wbm-php-pear-1.5-1

php-5.3.8-2.el5.art

php-pgsql-5.3.8-2.el5.art

php-odbc-5.3.8-2.el5.art

php-cli-5.3.8-2.el5.art

php-devel-5.3.8-2.el5.art

php-mysql-5.3.8-2.el5.art

php-pdo-5.3.8-2.el5.art

php-mbstring-5.3.8-2.el5.art

php-snmp-5.3.8-2.el5.art

php-xmlrpc-5.3.8-2.el5.art

php-pear-1.7.2-2.el5.art

php-common-5.3.8-2.el5.art

php-gd-5.3.8-2.el5.art

php-bcmath-5.3.8-2.el5.art

php-imap-5.3.8-2.el5.art

php-xml-5.3.8-2.el5.art

php-ioncube-loader-4.0.10-1.el5.art

Any help would be appreciated

Tue, 12/13/2011 - 22:37 (Reply to #5)
andreychek

Well, the same advice applies here -- you'd need to find a way to reduce how many modules you're loading into Apache and PHP.

Each of the packages you're listing above cause PHP to use more memory -- so you should remove any that you don't need.

Also, by using a 64 bit system rather than a 32bit system, you're using twice as much RAM. I'd highly suggest a 32 bit system unless you have more than 3GB of memory.

-Eric

Wed, 12/14/2011 - 16:29 (Reply to #6)
vectorsites

Well that's all fine but everything was the same and only got bad after I upgraded with the atomic repo. Are there some new settings I may have missed?

Wed, 12/14/2011 - 17:05 (Reply to #7)
andreychek

Well, my hunch there is that the newer PHP version you're getting from Atomic requires more RAM.

How much RAM is on your system though? You can determine that by running this command:

df -h

Thu, 12/15/2011 - 09:31 (Reply to #8)
vectorsites

We upped it due to the rise of used ram but...

Filesystem Size Used Avail Use% Mounted on /dev/simfs 100G 14G 87G 14% / none 1.3G 4.0K 1.3G 1% /dev

Thu, 12/15/2011 - 10:03 (Reply to #9)
andreychek

Ahh darnit, I gave you the wrong command :-)

The one I'm really interested in is this one: free -m

Thu, 12/15/2011 - 12:19 (Reply to #10)
vectorsites
         total       used       free     shared    buffers     cached

Mem: 2560 1507 1052 0 0 0 -/+ buffers/cache: 1507 1052 Swap: 0 0 0

Tue, 08/30/2011 - 10:06
carloxp

mod_php Apache is not a required module?

The output is:

rpm -qa | grep php-

php-eaccelerator-5.3.6_0.9.6.1-1.el5.art php-xml-5.3.6-5.el5.art php-devel-5.3.6-5.el5.art php-common-5.3.6-5.el5.art php-mcrypt-5.3.6-5.el5.art php-pdo-5.3.6-5.el5.art php-5.3.6-5.el5.art php-gd-5.3.6-5.el5.art php-odbc-5.3.6-5.el5.art php-snmp-5.3.6-5.el5.art php-imap-5.3.6-5.el5.art php-mbstring-5.3.6-5.el5.art php-mysql-5.3.6-5.el5.art wbm-php-pear-1.5-1 php-pear-1.8.0-1.el5.vm php-cli-5.3.6-5.el5.art php-pgsql-5.3.6-5.el5.art php-xmlrpc-5.3.6-5.el5.art php-mcrypt-5.3.6-5.el5.art

Please, note that I upgraded to PHP 5.3 because the only repo I found (atomic) containing eAccelerator required such PHP upgrade

Tue, 08/30/2011 - 10:07
carloxp

Sorry for bad output. Retry:

rpm -qa | grep php-

php-eaccelerator-5.3.6_0.9.6.1-1.el5.art

php-xml-5.3.6-5.el5.art

php-devel-5.3.6-5.el5.art

php-common-5.3.6-5.el5.art

php-mcrypt-5.3.6-5.el5.art

php-pdo-5.3.6-5.el5.art

php-5.3.6-5.el5.art

php-gd-5.3.6-5.el5.art

php-odbc-5.3.6-5.el5.art

php-snmp-5.3.6-5.el5.art

php-imap-5.3.6-5.el5.art

php-mbstring-5.3.6-5.el5.art

php-mysql-5.3.6-5.el5.art

wbm-php-pear-1.5-1

php-pear-1.8.0-1.el5.vm

php-cli-5.3.6-5.el5.art

php-pgsql-5.3.6-5.el5.art

php-xmlrpc-5.3.6-5.el5.art

php-mcrypt-5.3.6-5.el5.art

Tue, 08/30/2011 - 10:25
andreychek

Well, the PHP version you have there is fine... but that is a decent amount of modules, and could certainly be contributing to the amount of RAM that you're seeing is in use.

If there's any of the above that you don't need, I'd suggest removing or disabling them.

You may also want to disable mod_php if you don't require it, as that would free up some RAM as well.

-Eric

Tue, 08/30/2011 - 10:28
carloxp

Ok. Eric. I will try to disable some useless or unused modules, but I doubt I will find some...

Thank you very much for the support :-)

Tue, 08/30/2011 - 10:34
carloxp

Do you think that downgrading to a 32 bit system can help me in order to reduce memory consumption?

Tue, 08/30/2011 - 10:39
andreychek

You will use roughly half the RAM you're using now, simply by moving from a 64 bit system to a 32 bit system.

I also doubt you'll notice a performance difference, though that certainly depends on your applications and the sort of usage you're seeing.

Before you do that though -- what is the output of "free -m" on your system?

Also, can you run "ps auxw", and attach the resulting output to this thread?

Thanks,

-Eric

Tue, 12/13/2011 - 20:26
helpmin

Yes, 32 bit would save memory.

BTW, do you have an OpenVZ VPS?

Topic locked