It was thus said that the Great dtufs once stated:
> 
> The Apache server runs on Debian 3.1 (latest stable),
> 2.4.x kernel.
> 
> The following modules are loaded:
> 
> mod_php4.c, mod_ssl.c, mod_setenvif.c, mod_expires.c,
> mod_auth.c, mod_access.c, mod_rewrite.c, mod_alias.c,
> mod_cgi.c, mod_dir.c, mod_autoindex.c, mod_info.c,
> mod_status.c, mod_negotiation.c, mod_mime.c,
> mod_mime_magic.c, mod_log_config.c, mod_chroot.c,
> mod_macro.c, mod_so.c, http_core.c
> 
> I'm not sure if all are needed. MySQL is needed
> because of our forum (phpbb).
> 
> We really need to reduce it from 5MB to 1.5 MB or
> less. Any help will be greatly appreciated. Thanks.

  Well, you could try removing one or two modules but they really won't
reduce the footprint that much (with the exception of mod_php4---removing
*that* would easily cut the size of Apache in half, but I doubt you want to
remove that one) but what are you *really* trying to accomplish?

  Now, that 5MB figure you give for Apache---how did you get that?  If it's
from the executable size, that's not a good indication of how big the
program is.  Here's Apache on one of the servers I run:

-rwxr-xr-x  1 root root 6233704 Apr  4 22:32 httpd

  6MB executable, which consists of:

Compiled-in modules:
  http_core.c
  mod_env.c
  mod_log_config.c
  mod_mime.c
  mod_negotiation.c
  mod_status.c
  mod_info.c
  mod_include.c
  mod_autoindex.c
  mod_dir.c
  mod_cgi.c
  mod_asis.c
  mod_imap.c
  mod_actions.c
  mod_userdir.c
  mod_alias.c
  mod_rewrite.c
  mod_access.c
  mod_auth.c
  mod_proxy.c
  mod_setenvif.c
  mod_ssl.c
  mod_perl.c
  mod_php4.c
  mod_litbook.c (custom module I wrote in case anyone is curious)

But, that 6M figure *isn't* the size of the actual executable.  No, for
that, you need:

GenericUnixPrompt> size httpd
   text    data     bss     dec     hex filename
2009817   83880   42732 2136429  20996d httpd

The actual *code* segment is 2M in size, with about another 100k or so of
data.  What's the other 4M in the executable?  Oh, debugging type
information that's only needed when the program crashes---it's not loaded. 
Now, keep track of that 2M in the "text" segment of Apache.  That portion
will be shared among *all* running instances of Apache in your system, so
even with 50 Apache processes running, the code itself (not the data or the
bss segments) will only consume 2M *at most* (of the Apache
executable---there are also shared libraries to consider but I'll get to
that in a bit); each process will get its own copy of the data and bss
segments (and even then, only if it changes---as long as the data portions
haven't changed, they will be shared among processes).

To get an indication of just how much RAM Apache is actually using, do a "ps
aux" and look for all the Apache processes (which I did on my server,
cleaned the output a bit):

USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND
root     12191  0.0  0.5 10312 5624 ?        S    Apr04   3:53 
/usr/local/apache/bin/httpd
www       1129  0.0  0.6 10552 6516 ?        S    Jul27   0:01 
/usr/local/apache/bin/httpd
www       1130  0.0  0.6 10552 6504 ?        S    Jul27   0:01 
/usr/local/apache/bin/httpd
www       1131  0.0  0.6 10556 6508 ?        S    Jul27   0:01 
/usr/local/apache/bin/httpd
www       1231  0.0  0.6 10636 6468 ?        S    Jul27   0:01 
/usr/local/apache/bin/httpd
www       1504  0.0  0.6 10584 6528 ?        S    00:36   0:01 
/usr/local/apache/bin/httpd
www       1881  0.0  0.6 10600 6464 ?        S    01:30   0:01 
/usr/local/apache/bin/httpd
www       1904  0.0  0.6 10548 6460 ?        S    01:37   0:01 
/usr/local/apache/bin/httpd
www       2007  0.0  0.6 10556 6500 ?        S    01:53   0:01 
/usr/local/apache/bin/httpd
www       2008  0.0  0.6 10556 6456 ?        S    01:53   0:01 
/usr/local/apache/bin/httpd
www       2191  0.0  0.6 10556 6436 ?        S    02:17   0:01 
/usr/local/apache/bin/httpd
www       2392  0.0  0.6 10560 6516 ?        S    02:42   0:01 
/usr/local/apache/bin/httpd
www      10620  0.0  0.6 10508 6388 ?        S    03:35   0:01 
/usr/local/apache/bin/httpd
www      10623  0.0  0.6 10552 6528 ?        S    03:35   0:00 
/usr/local/apache/bin/httpd
www      10632  0.0  0.6 10556 6456 ?        S    03:37   0:01 
/usr/local/apache/bin/httpd
www      10637  0.0  0.6 10548 6436 ?        S    03:37   0:01 
/usr/local/apache/bin/httpd
www      11011  0.0  0.6 10552 6452 ?        S    04:32   0:00 
/usr/local/apache/bin/httpd
www      11014  0.0  0.6 10548 6452 ?        S    04:32   0:00 
/usr/local/apache/bin/httpd
www      11837  0.0  0.6 10556 6448 ?        S    06:25   0:00 
/usr/local/apache/bin/httpd
www      11975  0.0  0.6 10556 6496 ?        S    06:44   0:01 
/usr/local/apache/bin/httpd
www      12252  0.0  0.6 10532 6472 ?        S    07:24   0:00 
/usr/local/apache/bin/httpd
www      19452  0.0  0.5 10452 5956 ?        S    12:59   0:00 
/usr/local/apache/bin/httpd
www      19459  0.0  0.5 10448 6128 ?        S    12:59   0:00 
/usr/local/apache/bin/httpd
www      19461  0.0  0.5 10444 5904 ?        S    12:59   0:00 
/usr/local/apache/bin/httpd
www      19462  0.0  0.5 10456 5928 ?        S    12:59   0:00 
/usr/local/apache/bin/httpd
www      19470  0.0  0.5 10312 5788 ?        S    12:59   0:00 
/usr/local/apache/bin/httpd

You want to look at the RSS column, which is reported in kilobytes.  RSS in
this case stands for "Resident Set Size", and is the actual portion of the
program in memory (VSZ or "Virtual Size" is how much memory the program is
"using")---yes, each instance is using about 6M of RAM, but most of that is
shared.  And why, if the executable portion is only 2M is each working set
nearly 6M?  Well, shared libraries for one:

        /lib/ld-2.3.3.so
        /lib/libc-2.3.3.so
        /lib/libcrypt-2.3.3.so
        /lib/libdl-2.3.3.so
        /lib/libm-2.3.3.so
        /lib/libnsl-2.3.3.so
        /lib/libnss_compat-2.3.3.so
        /lib/libnss_dns-2.3.3.so
        /lib/libnss_files-2.3.3.so
        /lib/libnss_nis-2.3.3.so
        /lib/libpthread-0.10.so
        /lib/libresolv-2.3.3.so
        /lib/libutil-2.3.3.so
        /lib/libz.so.1.2.1
        /usr/lib/libcrypto.so.0.9.7
        /usr/lib/libdb1.so.2
        /usr/lib/libexpat.so.0.4.0
        /usr/lib/libperl.so.1.5.8
        /usr/lib/libssl.so.0.9.7

And any data that has changed (which page to serve for instance).  So of
those 6M each instance is using, perhaps 4-5M is shared between all
instances (and with the case of /lib/libc-2.3.3.so, *all* the processes will
share that particular library).

  So while you *might* be able to get the actual executable down to 1.5M, it
doesn't really mean *anything*, since a significant portion of the
executable is shared among all instances.  

  Now, if it's an instance of saving space on the disk, then all you need to
do is run "strip httpd" (and when I did that on my copy, Apache went from
being 6233704 bytes to 2117812 bytes; doing so won't affect Apache running,
but it will make it difficult to debug or analyse core dumps).

  -spc (Sorry for all this dull technical information ... )




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to