Apache eating Memory

Posted by andrei155, 04-20-2009, 10:31 PM
Apache is wasting away a bit over a GB of memory at about 100 connections. Is this something normal? Or should I be receiving a little better performance? Also, I find that the load is very low. Is there anyway to sort of trade a bit of the CPU Usage for some more memory?

Posted by LoganNZ, 04-20-2009, 11:07 PM
What OS, control panel? Also whats your httpd.conf like?

Posted by andrei155, 04-20-2009, 11:09 PM
CentOS 5, cPanel The only changes in the conf file worth mentioning are: Timeout 180 StartServers 3 MinSpareServers 2 MaxSpareServers 5 ServerLimit 100 MaxClients 100 MaxRequestsPerChild 2000 KeepAlive On KeepAliveTimeout 2

Posted by lemeneid, 04-21-2009, 01:04 AM
Whats your system specs? From the looks of what you have now, change the timeout to 60 secs and turn off keepalive

Posted by andrei155, 04-21-2009, 01:09 AM
The system is a Core 2 Quad 2.66Ghz with 2GB RAM

Posted by LoganNZ, 04-21-2009, 01:24 AM
Turn off keepalive and enable apache memory limit.

Posted by Deem3n®, 04-21-2009, 07:06 AM
You can also try to cache static content like images, html files etc. Try to use nginx or squid as reverse proxy for that.

Posted by barry[CoffeeSprout], 04-21-2009, 07:42 AM
Keep in mind that PHP scripts are included in this figure. What are you running?

Posted by andrei155, 04-21-2009, 07:43 AM
What am I running in terms of what? Also by Apache memory Limit, were you referring to the RLimitMEM command? What is an appropriate setting for this?

Posted by barry[CoffeeSprout], 04-21-2009, 07:46 AM
Are you running PHP sites and what kind of sites? Depending on the script and your settings a PHP request can take up to a few megabytes for the duration of that request. You mention having about 100 connections running, so it could be just that

Posted by andrei155, 04-21-2009, 07:48 AM
Well I would also have to put PHP into consideration. I mean, I run a hosting company, I can't just deny them access to it. I just feel that apache should be able to handle more requests without eating so much of the systems resources. Am I incorrect in my assumption?

Posted by barry[CoffeeSprout], 04-21-2009, 08:46 AM
You are if most of the memory is used by PHP Seriously though if you run php_mod PHP will run "in process" with the Apache worker process and thus the memory usage for PHP is added to apache. This memory is reclaimed after a request when the request thread / process is torn down. If you were running only static (HTML, images.. etc) content then yes it would be odd to see so much in use with Apache. 100 Concurrent connections on PHP with 1 GB does not strike me as entirely odd. (though maybe on the heavy side)

Posted by andrei155, 04-21-2009, 05:38 PM
Well, let's put it this way: I'm running CentoOS 5 and cPanel/ WHH on a Core 2 Quad 2.66Ghz with 2GB RAM system. At around 112 Apache connections, the system has no more Memory left over (Maybe 100 MB). Currently, ps -def | grep httpd | grep -v grep | wc -l reports 56. Top reports: If I turn off apache (I just did so), top reports: If I turn off apache, named, lfd, mysql, cpanel, and exim - top reports: So, something is still using up 400 MB. Here's the whole of the top output: So, from the looks of it, apache is really using up most of the memory. 1GB per 100 or so connections. Everything else uses up another 600 MB, and then there's just 400 MB being used by the system itself - I guess. During all of this time (while memory is being devoured) the CPU usage is very low. Is there anyway to let my CPU handle some of the work, so that the memory clears up? Or, is there anything I could do to stop apache from eating a Gig for every 100 connections? Last edited by andrei155; 04-21-2009 at 05:45 PM.

Was this answer helpful?

 Print this Article

Also Read

utf-8, hebrew, chinese ....

Posted by joonas, 10-31-2012, 09:00 AMi have a collection of international html documents...

Whats better.....

Posted by creid, 09-10-2001, 03:06 PMHi! I was wondering what you guys think is better. Plan...

partition disk (/) 80% full - need advice

Posted by activa, 09-12-2007, 08:52 PMhello all . i have the partition (/) 80% full ; what...

cobol Class need help with code.

Posted by slayer1189, 10-24-2012, 11:56 AMI am trying to have the program sort through the input...

CPanel - Change email password without logging into Cpanel

Posted by keith70, 03-14-2007, 12:48 PMIs there a script out there that will allow a user to...