do i have too many apache processes?

young

Verified User
Joined
Oct 22, 2003
Messages
84
is something wrong if the show services page looks like this:

Service Status Start Stop Restart Reload
Apache httpd (pid 22691 22692 22693 22694 22695 22696 22697 22698 23816 23817 23818 23819 23820 23821 23822 23823 23824 23825 23826 23827 23828 23829 23830 23864 23865 23866 23867 23868 23869 23870 23871 23872 23873 23874 23875 23876 23877 23878 23879 23907 23908 23909 23910 23912 23913 23914 23915 23916 23917 23918 23919 23920 23921 23922 23923 23924 23925 23926 23927 23928 ) Start Stop Restart Reload
 
Not necessarily. Lots of hits require lots of processes. Apache starts up new processes to handle the load when necessary. Of course if your box isn't serving any large number of pages you might start to worry.

It's more interesting to look at the detailed status page which tells you which URL each process is currently serving (e.g. there might be an AVI that's getting hammered).

Also check the configuration directions in httpd.conf that set how many servers to start initially, max servers etc.
 
Uhmm i have the same problem at the moment and my load is getting higher and higher...
Please help me asap...

httpd (pid 24784 24677 24672 24641 24291 24219 24044 23803 23475 23195 22945 22691 22567 22273 22272 22271 22270 22268 22267 22263 22262 22261 22260 22250 22249 22243 22242 22241 22239 22238 22237 22236 22228) is running...
 
Guys that is the process id's. That is completely normal. You can verify this information from:

#ps aux| grep httpd

If you don't want this many processes then you can change the settings (no recommened) by searching the httpd.conf file for

-Timeout
-MaxKeepAliveRequests
-KeepAliveTimeout
-MinSpareServers
-MaxClients

To learn more about each (rather than posting long here) search the documents from the apache website

http://search.apache.org/
 
It's more that if someone refreshes a website alot that apache generates like 50 load or so.... That is not good is it?
 
If someone refreshes their browser in enough time it should not open a new pid because they have not timed out yet. The problem is newer browsers (Mozilla/Netscape, Safari, etc) can actually spawn multiple threads (pid's) while grabbing websites. This is how they help improve the rendering time.

To give you a idea this is from one of our customers boxes it moved in the last 18 days 81428MB the entire website is less than 4MB to that tells you how many people surf that website...

httpd (pid 30448 30446 30430 30429 30428 30413 30406 30405 30401 30399 30388 30384 30383 30376 30359 30357 30351 30348 30329 30328 30327 30326 30301 30300 30296 30288 30287 30282 30276 30269 30268 30267 30264 30256 30254 30253 30239 30237 30235 30210 30200 30196 30190 30184 30182 30172 30165 30162 30158 30157 30156 30155 30134 30133 30132 30131 30102 30098 30095 30094 30078 30077 30076 30051 30049 30044 30043 30035 30034 30033 30003 29997 29986 29980 29979 29952 29951 29949 29923 29917 29905 29899 29892 29

That is just SOME the pid's. Their are so many connections that DA does not list them all. The person that leases this server could help lower the RAM usage if he lowered his timeout. The only problem is you could end up with, in this type of load, using more memory since you are not keeping a connection alive, but spawing more of them.

It is a fine line between long timeout's and short timeout's. You can use the top command to figure out how much httpd is using and adjust as necessary.
 
Since the last update I am having apache load problems.

httpd (pid 29161 29159 29158 29157 29156 29155 29154 29153 29152 29151 29150 29149 29148 29147 29146 29145 29144 29143 29142 29141 29140 29139 29138 29137 29136 29135 29134 29133 29132 29131 29130 29129 29128 29127 29126 29125 29124 29123 29122 29121 29120 29119 29118 29117 29116 29115 29114 29113 29112 29111 29110 29109 29108 29107 29106 29105 29104 29103 29102 29101 29100 29099 29098 29097 29096 29095 29094 29093 29092 29091 29090 29089 29088 29087 29086 29085 29084 29083 29082 29081 29080 29079 29078 29077 29076 29075 29074 29073 29072 29071 29070 29069 29068 29067 29066 29065 29064 29063 29062 29061 29060 29059 29058 29057 29056 29055 29054 29053 29052 29051 29050 29049 29048 29047 29046 29045 29044 29043 29042 29041 29040 29039 29035 29034 29033 29032 29031 29030 29029 29028 29027 29026 29025 29024 29023 29022 29021 29020 29019 29018 29017 29016 29015 29014 29013 29012 29011 29010 29009 29008 29007 29006 29005 29004 29003 29002 29001 29000 28999 28998 28997 28996 28995 28994 28993 28992 28991 28990 28989 28988 28987 28986 28985 28984 28983 28982 28981 28980 28979 28978 28977 28976 28975 28974 28973 28972 28971 28970 28969 28968 28967 28966 28965 28957) is running...
 
Hello,

DA doesn't change the httpd settings that control process spawing and timeouts. You can edit them by modifying:

-Timeout
-MaxKeepAliveRequests
-KeepAlive
-KeepAliveTimeout
-MinSpareServers
-MaxClients

just as existenz said. You can try to decrease the Timeout, you can decrease the MaxClients (not too low), but as more people visit your server, more processes are spawned to accomodate everyone.

Another thing you can try is to set KeepAlive to On. This will enable people to make multiple requests through the same apache process, which prevents the need for as many apache processses. Just play with those settings to suite your needs.

John
 
How do you see a detailed status page I really want to see why this is all happening there is only 2-3 sites on the server and barely any of them get traffic.
 
Hello,

DA doesn't change the httpd settings that control process spawing and timeouts. You can edit them by modifying:

-Timeout
-MaxKeepAliveRequests
-KeepAlive
-KeepAliveTimeout
-MinSpareServers
-MaxClients

just as existenz said. You can try to decrease the Timeout, you can decrease the MaxClients (not too low), but as more people visit your server, more processes are spawned to accomodate everyone.

Another thing you can try is to set KeepAlive to On. This will enable people to make multiple requests through the same apache process, which prevents the need for as many apache processses. Just play with those settings to suite your needs.

John

I have updated with custombuild using this:
"./build update_versions"

And also used this tutorial to upgrade from mysql 4 to mysql 5.1: http://help.directadmin.com/item.php?id=240

Some of the databases of my customers got corrupt (mostly joomla) but i just restored backups. However, since the update, the server load doesnt EVER drop below 4.00 while it normally dropped below 1.00 like 90% of the day.

So then I thought, maybe Apaches settings are messed up, I then ran ./build rewrite_confs

Still, no change. I even suspended one of my users and told him his website was not suitable for shared hosting and got one angry customer, but still, no changes. The server load remains high and the /serverstatus page is the same is it was before. No proxy websites or anything else.

So I just saw this topic and I saw that I need to change this configuration, but in /etc/httpd/conf/httpd.conf I dont find any of these configurations. Can you please tell me where to edit these settings? I am sure the update has overwritten these settings and thats why the server is so slow.

I hope someone can help me fast...
 
The settings were moved into /etc/httpd/conf/extra folder. Not sure what file though. I dont have access to my directadmin server here.
 
Thank you, this file is etc/httpd/conf/extra/httpd-default.conf

PHP:
#
# This configuration file reflects default settings for Apache HTTP Server.
#
# You may change these, but chances are that you may not need to.
#

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 60

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 1

#
# UseCanonicalName: Determines how Apache constructs self-referencing 
# URLs and the SERVER_NAME and SERVER_PORT variables.
# When set "Off", Apache will use the Hostname and Port supplied
# by the client.  When set "On", Apache will use the value of the
# ServerName directive.
#
UseCanonicalName Off

#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride 
# directive.
#
AccessFileName .htaccess

#
# ServerTokens
# This directive configures what you return as the Server HTTP response
# Header. The default is 'Full' which sends information about the OS-Type
# and compiled in modules.
# Set to one of:  Full | OS | Minor | Minimal | Major | Prod
# where Full conveys the most information, and Prod the least.
#
ServerTokens Major

#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory 
# listings, mod_status and mod_info output etc., but not CGI generated 
# documents or custom error documents).
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
# Set to one of:  On | Off | EMail
#
ServerSignature On

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off




<IfModule mod_rewrite.c>
	RewriteEngine on
	RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
	RewriteRule .* - [F]
</IfModule>

It all looks right to me, am I right? So this isnt the problem either?
 
If you are running Apache2, what you are interested in is the /etc/httpd/conf/extra/httpd-mpm.conf file. That's where the MPM modules are configured. By default Apache uses the "prefork" MPM, which fork a process for every request (that is not served by KeepAlive).

If you have high load websites, move from prefork to worker, this way there will be threads instead of processes, sharing memory, locks and other things between them and freeing some resources.
Just go to /usr/local/directadmin/custombuild, copy configure/ap2/configure.apache to custom/ap2/configure.apache, add --with-mpm=worker to the list inside that file and run "./build apache n".
All configuration for worker is also in the httpd-mpm.conf file.
 
If you are running Apache2, what you are interested in is the /etc/httpd/conf/extra/httpd-mpm.conf file. That's where the MPM modules are configured. By default Apache uses the "prefork" MPM, which fork a process for every request (that is not served by KeepAlive).

If you have high load websites, move from prefork to worker, this way there will be threads instead of processes, sharing memory, locks and other things between them and freeing some resources.
Just go to /usr/local/directadmin/custombuild, copy configure/ap2/configure.apache to custom/ap2/configure.apache, add --with-mpm=worker to the list inside that file and run "./build apache n".
All configuration for worker is also in the httpd-mpm.conf file.

Excellent, thank you. I will try this in a few minutes, hope it will work. I will post here and if it works, man, I will kiss your feet :)
 
add --with-mpm=worker to the list inside that file and run "./build apache n".

I added that to
/usr/local/directadmin/custombuild/configure/ap2/configure.apache

is that correct or should I add that to
/usr/local/directadmin/custombuild/custom/ap2/configure.apache
?

Current error SSH gives me:
PHP:
server:/usr/local/directadmin/custombuild# ./build apache n
File already exists:    httpd-2.2.11.tar.gz
MD5 Checksum on httpd-2.2.11.tar.gz passed.
File already exists:    httpd_2
File already exists:    httpd_2_freebsd
File already exists:    httpd_2_debian
Backing up certificate and key, and turning off httpd for DirectAdmins's check.
Found /usr/local/directadmin/custombuild/httpd-2.2.11.tar.gz
Extracting /usr/local/directadmin/custombuild/httpd-2.2.11.tar.gz...
Configuring httpd-2.2.11
./build: line 5613: /usr/local/directadmin/custombuild/custom/ap2/configure.apache: Permission denied

*** There was an error while trying to configure Apache 2. Check the custom/ap2/configure.apache file

so I then removed it from that file and added it to
usr/local/directadmin/custombuild/custom/ap2/configure.apache

then it still gave me the permission denied thing, so I changed the permissions to 777

SSH is doing its job now...

In the end I got this:

PHP:
Restarting apache.
Stopping httpd:
Remaining processes: 27975
Stopping httpd:
Starting httpd: [Thu Mar 26 19:54:46 2009] [crit] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe.  You need to recompile PHP.
Pre-configuration failed

So httpd was down and I couldnt restart it with DirectAdmin GUI so I now have rebooted it... did I do anything wrong?
 
I should have told you :) you also need PHP as CGI to have a threaded MPM. mod_php is not threading safe, it won't work.
 
:confused: great :mad:

now the server is offline and after the reboot not even directadmin works completely, so i removed the line again from the file and am building apache once more, it'll probably want me to reboot again

great :(
 
You don't have to reboot, nor to recompile apache.
Just modify options.conf, set php as CGI instead of CLI and run ./build php n :p then you will be able to restart apache.
 
You don't have to reboot, nor to recompile apache.
Just modify options.conf, set php as CGI instead of CLI and run ./build php n :p then you will be able to restart apache.

Ok, the server is online now and working fine. If I set PHP as CGI in options.conf and try it again, it will work? You this time didnt forget anything else to say? Cause I now already have to refund my customers for March because of the 99,9% uptime for this month wasnt realised lol :p
 
Back
Top