Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I come here because I have searched and tried different optimization without finding any answers.

We have a server with four websites hosted. The frequentation is not very high (we are sure that the problem is not the number of visitors).

We have a LAMP architecture (Centos 6.4, Apache, MySQL and PHP in the latest version). We also use eaccelerator. On a recent server 16GB DDR3, Intel Xeon E3 (4 cores @3.1 GHz).

Apache has a basic configuration with a few modules disabled and few to try to resolve our problem. MaxClients = 150 and MaxRequestsPerChild = 100.

Our problem is that some apache process inflates on weight up to several GB (I have seen one at 12GB !!! it was launched since15 minutes). At most processes live a long time more they grow with a large CPU usage... Then monitoring restart Apache...

I had no idea where the problem can come. The Apache log show nothing abnormal. This problem occurs both during the day than at night and it seems random.

thank you for your help.

share|improve this question
You probably have a php application with a memory leak. Something in the process consumes memory and doesn't release it. It might help to mention the php applications you're running on that web server. – Fiasco Labs Jul 4 '13 at 22:47
Thanks. It's an home made application, no CMS, no Framework. Do you know how to investigate a memory leak ? – Florian Jul 5 '13 at 7:13
Most likely, it was 12GB of virtual memory (address space), not physical memory (RAM). A 64-bit OS can make terabytes of virtual memory at effectively zero cost, so that's not your problem. (If you think it's actually using that much physical memory, please paste the exact output you got. It's likely you are misinterpreting it.) – David Schwartz Jul 5 '13 at 7:34
To check the size of each Apache process I read the RSS column of this command : ps -y -l -C httpd --sort:rss In the same time I run free -m and the free memory is very low. I use Monit to restart Apache if it use more than 2GB for a couple of minutes. – Florian Jul 5 '13 at 7:42
@Florian: That's fine, so long as you realize that the Apache processes are sharing the vast majority of that memory. And free memory should be very low. Free memory is just lost opportunity. – David Schwartz Jul 5 '13 at 13:49

Several runtimes can run as apache in-process plugins, mod_php being the most common one.

In that case, any memory used by PHP is allocated by apache. As a rule, once the process grows to a given size, it will not shrink. After the PHP script is done executing, the Apache process which contained it can still keep the memory allocated. Assuming the next PHP page request hits a different apache process, you may find apache holding much more memory than is necessary.

The first place I'd look is the maximum allowable memory size for PHP, bearing in mind that the value can be changed at run-time by the PHP script. There's a limit for a reason; set the limit to something reasonable bearing in mind that the total memory consumption will be the number of running processes multiplied by the per-process limit.

A workable long-term solution is to take PHP out of the Apache process; run under fastCGI using mod_fcgid, for example. This allows you to specify a limit on the number of PHP processes which is lower than the number of apache processes. Since apache is used to serve more than just PHP, and therefore probably requires more processes than PHP, separating the two out allows you to make more efficient use of your resources at hand.

share|improve this answer
thank you for your answer, we'll try it. With ISPConfig it seems relatively simple to implement. We will try on the night (we are in France) for not affected our customers. – Florian Jul 8 '13 at 7:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.