0

I have a question that maybe you can help me to answer. When I execute ps -aux from 00:00 to 00:03 I get about 30-40 apache processes but visits in such period of time are only 2 (Google Analytics). Why is this happening? All that Apache processes are eating my RAM...

Thanks in advance

LuisClemente
  • 117
  • 4

2 Answers2

4

Apache keeps a number of processes 'waiting for action'. That number is set in your httpd.conf file. Whenever a new request comes in, Apache will direct the request to one of the available processes. The number might drop a little when some processes are not in use, but there is typically a lower bound to how much it will drop.

Depending on whether you use 'Worker' or 'Prefork' as your process manager, the settings are slightly different:

From httpd.conf:

prefork MPM

  • StartServers: number of server processes to start
  • MinSpareServers: minimum number of server processes which are kept spare
  • MaxSpareServers: maximum number of server processes which are kept spare
  • ServerLimit: maximum value for MaxClients for the lifetime of the server
  • MaxClients: maximum number of server processes allowed to start
  • MaxRequestsPerChild: maximum number of requests a server process serves

worker MPM

  • StartServers: initial number of server processes to start
  • MaxClients: maximum number of simultaneous client connections
  • MinSpareThreads: minimum number of worker threads which are kept spare
  • MaxSpareThreads: maximum number of worker threads which are kept spare
  • ThreadsPerChild: constant number of worker threads in each server process
  • MaxRequestsPerChild: maximum number of requests a server process serves

Chances are that you have your 'StartServers' and 'MinSpareServers' set quite high. Take a look at this page on optimizing Apache for low memory.

cyberx86
  • 20,805
  • 1
  • 62
  • 81
0

You should also note that visits in Google Analytics only represent that one client connected. They do not necessarily indicate their activities on the site (there are tools in Analytics for this). Your two clients could have been hammering Apache hard with multiple tabs open or something similar.

Furthermore, Apache processes don't go away immediately (unless you tell them to); those spare processes from 00:00 to 00:03 could have been from visitors prior to 00:00 that Analytics for 00:00 to 00:03 will not show. A window of 3 minutes is not terribly useful to you. You're better off looking at metrics for an entire day or week at a time to get a good feel for how to best configure your Apache child processes.

Joel
  • 191
  • 1