Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a big problem with my apache2. I am on LAMP with debian 6, 64bit.

Here a screen after 24h of running, ordered by %MEM:

you can see VIRT for apache2 is 186mb.

That's not good at all. What Can I do?

Consider this apache servs only a couple of virtual host, and PHP pages doenst' require more than 3MB of memory.

<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    ServerLimit      1250
    MaxClients            1250
    MaxRequestsPerChild   1500
</IfModule>

Thanks

share|improve this question
    
Can you please post the configuration related to mpm_prefork? –  Mircea Vutcovici Mar 9 '11 at 16:35
    
@mircea: look first post –  dynamic Mar 9 '11 at 16:39

4 Answers 4

up vote 4 down vote accepted

Is it that big of a problem?

The VIRT field that you are using is the total amount of memory the process could use. The next column is closer to the amount it is using. Even then some of this will be shared between processes. I would recommend reading up how Linux manages virtual memory if you are going to be doing Linux admin.

Looking at the other stats you still have a 1Gb of spare RAM so the box has not even tried to fill it's disk caches so it looks like there is plenty of RAM to spare.

Mahnsc is correct though, removing unused modules will help both memory and security.

Having said all that it does look a little large. Have they grown large? Does a restart reset to a smaller memory usage? If it is growing then that may be a problem but if it is mostly static then it may be okay.

share|improve this answer
    
I asked this becease 2 days ago apaches2 process ate up all the momery + swap memory.. and i had to restart the server (after 20-25 days of up) –  dynamic Mar 9 '11 at 14:44
    
Ah. Then that is not right! Sounds like a nasty memory leak. I assume you have all the latest updates installed. Might be a memory leak somewhere. Some useful info on php diagnostics: ibm.com/developerworks/opensource/library/os-php-v521 You may also want to look into something like FastCGI for running php as it may give you more control and allow you to isolate the problems. –  Choffee Mar 9 '11 at 15:14
    
this damn apache2 :@! anyway it's not related to php since on the previous server same php code didn't give any problem, and memory_limit is only at 16M –  dynamic Mar 9 '11 at 15:32
    
The ServerLimit is to high. –  Mircea Vutcovici Mar 9 '11 at 18:55
    
RAM usage is growing again :(. Now constantly at 50%. The more time passes the more RAM usage grows :( it's like apache2 processes size grows over time for a reason i can't get :( –  dynamic Mar 12 '11 at 17:14

The server limit is too big. Should be, depending on your application, something like 10x number of CPU cores. Run a load test with JMetter for the traffic you are expecting during high load. and then set the ServerLimit accordingly. I would start with 2 * #CPU cores and increase linearly until the performance during the load test starts to degrade.

share|improve this answer
    
serverlimit infulences the loaded %mem of single apache process? –  dynamic Mar 9 '11 at 17:09
    
Nope, only the loaded modules and the PHP scripts used by your application. Virtual memory (VIRT) is the memory requests by apache and resident set size (Res) is the memory actually allocated from physical memory. See man ps for details –  Mircea Vutcovici Mar 9 '11 at 17:48
    
considering serverlimit doenst' influences memory usage as you said it's useless to lower it –  dynamic Mar 9 '11 at 17:51
    
It will lower the overall memory usage. Not the usage of each process. So it is not useless. Just try a load test and see how your server is behaving. –  Mircea Vutcovici Mar 9 '11 at 18:45
    
For load testing you can use ab or JMeter. See: httpd.apache.org/docs/2.0/programs/ab.html and jakarta.apache.org/jmeter –  Mircea Vutcovici Mar 9 '11 at 18:51

If you want to measure the actual memory footprint of apache, then the way to do it is to compare the output of 'free' with the number of httpd processes.

As mahnsc says - you should strip out the stuff you don't need from the httpd (you could strip the symblols too - but its not that big a saving).

only a couple of virtual host, and PHP pages

Maybe - it depends on what the code is actually doing. You might consider switching to fastCGI (it doesn't help the memory usage - but it allows you to see whether the problem is with apache or PHP).

Regardless there's little evidence that its actually affecting performance.

share|improve this answer

Unload any modules that you are not using or intending to use. If you're using php and don't need the mod_proxy or mod_jk support, unload them. That should help reduce the footprint of each child. You can unload most of the mod_auth_* and mod_authn_* modules as well if you aren't doing any kind of authentication by apache.

share|improve this answer

Your Answer

 
discard

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.