httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Greenaway <sresuehc...@davidgreenaway.com>
Subject Re: [users@httpd] Apache 2.0.49 flushing CGI script causes huge memory consumption
Date Mon, 31 May 2004 01:16:55 GMT
> >The following CGI script causes the Apache worker process to consume
> >huge amounts of memory (in my case, 'top' shows 526MB of virtual memory
> >allocated to the process), causing the system to grind to a crawl.
> >
> I tested your following script both with and without the flush. It seems 
> no problem. The excution time is about couple of sencods. My environment 
> is Win 2K pro, 125 MB memorey, Apache 2.0.47. What is the memory of your 
> computer? How long does it take? "Causing the system to grind to a 
> crawl' is not a much descriptive.

Quite correct. My apologies.

My box is a 550MHz Pentium III, with 256 MB memory. 

Here is what seems to happen when a page it requested:

1. apache2 child process memory jumps up to 500M.

2. Web page comes up in browser (about 400k of data)

3. apache2 child remains 500M for about 4 minutes before it finally
   dies. (I closed the browser just after the data came up to make sure
   KeepAlive wasn't keeping the process up, and I also had set
   'MaxRequestsPerChild' in the config file to 1).

Here is the output of 'top' after two requests to the script:

  PID  PPID nFLT    TIME+  %CPU %MEM  PR  NI S  VIRT SWAP  RES COMMAND
23176  2671  11k   0:08.61  0.0 41.9  18   0 R  574m 469m 105m apache2  <- mem.cgi
23175  2671 3460   0:09.93  1.4 40.7  18   0 R  464m 362m 101m apache2  <- mem.cgi
23211  2671    4   0:00.00  0.0  0.1  17   0 S  6828 6564  264 apache2  <- idle

I also ported the Perl script to compiled C and experienced the same
effects, so it doesn't appear to be a Perl issue.

Thanks,

-David


> >--- script start ---
> >#!/usr/bin/perl
> >
> >print "Content-Type: text/plain\n\n";
> >
> >$| = 1; # flush output
> >
> >for (my $i = 0; $i < 100000; $i++) {
> >       print "moo\n";
> >}
> >--- script end ---
> >
> >By turning off output flushing, the problem seems to go away.
> >
> >Obviously, having the output constantly flushing is not the most
> >efficient way to write CGI script, but it surprises me that it would
> >have such devastating effects. Is this a bug, or am I just missing
> >something? Can anybody else reproduce this?
> >
> >I am running Linux 2.6.4, Apache/2.0.49 (official Debian/Testing
> >package, version 2.0.49-1). The script is being run with 'cgi-script',
> >and *not* mod_perl.
> >

sresuehcapa@davidgreenaway.com
GPG: B81A E16D E0E9 02CD 4538  BD8D C416 F31A 09E4 413E

---------------------------------------------------------------------
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: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message