Memory consumption

Memory consumption

am 20.04.2008 12:24:16 von benjamin

Hello,

I'm currently using Apache 2.2 under Debian Etch, with FastCGI/Suexec
and Php5.2 (all of these softwares have been installed as Debian
paquets, using aptitude).

The server is a Pentium 4 (3 Ghz) with 2 Gb of RAM. It serves a lot of
requests (about 30 to 35 per second, mainly weblogs and forums). This
server is only used to run Apache and Proftpd. I recently switched
from Apache 1.3 to Apache 2.2, from php4 to php5 and from Debian Sarge
to Debian Etch (from scratch).
Since this major update I am running into memory consumption problems
with Apache 2 :

CPU load is correct, however memory consumption is really high : some
Apache 2 processes can take up to 10 % of total RAM, which is more or
less equal to 200 Mb :

15641 www-data 20 0 31416 16m 864 S 1 0.8 1:32.64apache2
3673 www-data 20 0 422m 114m 2416 S 0 5.7 0:10.87apache2
4364 www-data 20 0 408m 107m 3076 S 0 5.3 0:10.12apache2
5771 www-data 20 0 599m 207m 2028 S 0 10.3 0:20.58apache2

Here is the result of the "free" command :
-------------------------------------
total used free shared buffers cached
Mem: 2070444 1979116 91328 0 111444 1012000
-/+ buffers/cache: 855672 1214772
Swap: 923696 0 923696

I monitored the used memory (which is given by "-/+ buffers/cache")
and sometimes I noticed peaks to 1.6 Gb (which is really high); it
wasn't the case before the update, with the same traffic load.

Activated modules are :

actions.load authn_file.load authz_host.load bw.load dir.conf
fastcgi.conf negotiation.load status.load
alias.load authz_default.load authz_user.load cgid.conf dir.load
fastcgi.load rewrite.load suexec.load
auth_basic.load authz_groupfile.load autoindex.load cgid.load env.load
mime.load setenvif.load

And here are a few details about the Apache 2 version I'm using :
----------------------------------------
Server version: Apache/2.2.3
Server built: Jan 27 2008 18:09:58
Server's Module Magic Number: 20051115:3
Server loaded: APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture: 32-bit
Server MPM: Worker
threaded: yes (fixed thread count)
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/worker"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT=""
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
-D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"

I really hope some of you will be able to help me, I thank you all in advance.

Have a nice day !

Benjamin SCHILZ
bschilz@gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Memory consumption

am 20.04.2008 22:05:47 von Joshua Slive

On Sun, Apr 20, 2008 at 6:24 AM, benjamin wrote:
> Hello,
>
> I'm currently using Apache 2.2 under Debian Etch, with FastCGI/Suexec
> and Php5.2 (all of these softwares have been installed as Debian
> paquets, using aptitude).
>
> The server is a Pentium 4 (3 Ghz) with 2 Gb of RAM. It serves a lot of
> requests (about 30 to 35 per second, mainly weblogs and forums). This
> server is only used to run Apache and Proftpd. I recently switched
> from Apache 1.3 to Apache 2.2, from php4 to php5 and from Debian Sarge
> to Debian Etch (from scratch).
> Since this major update I am running into memory consumption problems
> with Apache 2 :

It's highly unlikely that this comes from apache or its core modules.
It is probably something in your php code or libraries.

One way to try to isolate the problem is to add the PID to your apache
access log. Then you can try to quickly identify processes that
balloon in size and track backward in the log to find requests that
could be causing it.

Joshua.

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: Memory consumption

am 21.04.2008 01:10:02 von Sean Conner

It was thus said that the Great benjamin once stated:
> Hello,
>
> I'm currently using Apache 2.2 under Debian Etch, with FastCGI/Suexec
> and Php5.2 (all of these softwares have been installed as Debian
> paquets, using aptitude).
>
> CPU load is correct, however memory consumption is really high : some
> Apache 2 processes can take up to 10 % of total RAM, which is more or
> less equal to 200 Mb :
>
> And here are a few details about the Apache 2 version I'm using :
> ----------------------------------------
> Server version: Apache/2.2.3
> Server built: Jan 27 2008 18:09:58
> Server's Module Magic Number: 20051115:3
> Server loaded: APR 1.2.7, APR-Util 1.2.7
> Compiled using: APR 1.2.7, APR-Util 1.2.7
> Architecture: 32-bit
> Server MPM: Worker
> threaded: yes (fixed thread count)
> forked: yes (variable process count)

I recently discovered that pthreads (the threading library used on most
Unix systems, including Linux) uses the process limit for the stack for each
thread it creates. You can check this value under Linux by running the
command "ulimit -s" at the command line.

[spc]lucy:~>ulimit -s
10240
[spc]lucy:~>

The value returned is in kilobytes, so the default stack size on my system
(CentOS) is 10M (and for a recent project I worked on, that explained why
the memory consumption was ridiculously huge---the program created a bunch
of threads).

You can decrease the amount of stack space by running the above command
with a value:

[spc]lucy:~>ulimit -s 128 # set maximum stack size to 128K

but be warned that pthreads will use a minimum amount of stackspace (it
checks if the process limit is too small, and if so, will use its minimum
size). This size is anywhere from 16k to 128k, depending upon the platform.
Also, setting the stack to a smaller value *may* cause Apache to crash (the
reason why a 10M stack segment isn't a problem is that the statck grows
on the fly as the program is running; pthreads can't do that for thread
stacks and has to allocate the memory when the thread is created).

-spc


------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org