httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kiss, John (GE Infra, Energy, Non-GE)" <john.k...@ge.com>
Subject [users@httpd] CGI Push and Apache memory consumption
Date Fri, 11 Jan 2008 20:48:02 GMT
 
Hello I'm having an issue with long running CGI push scripts causing
Apache to consume all available free memory over a period of several
days. 
 
The scenario : System free memory at 220 Megs, browser connects to cgi
push script. Within 3 days system free memory goes down and hovers at 5
megs but now other browsers cannot connect because of a lack of system
resources. Let the system run for two more days and Apache
kills/restarts it's threads and free memory returns to 220Megs and other
browser can connect to web pages again. Without ever resetting Apache I
let this cycle repeat over a 2 week period.
 
I've tested on a custom Linux system running Apache 2.0.55 under Linux
2.6.13 and on Ubuntu Feisty  which uses Apache 2.2.3 (using default
apache config). The same problem appears on both. Nothing special with
configuration and loading of modules.
 
I have attached a simple CGI script that replicates the issue (See
below) where Apache's memory grows linearly at a rate of ~19.6kB/min
(typically in 4kB increments depending on your Linux/MMU page size).. If
anyone has any insight on why this is happening and what I can do
resolve it, I would very be much appreciated it.
 
BTW, I have looked into this issue
(http://marc.info/?l=apache-httpd-users&m=112307824726606&w=2) already
discussed on this list and have found my issue is not related to range
headers since Apache 2.0.55 contains the patch (fix).
 
Cheers
John
 
------------------------------------------------------------------------
----------------------------------


Steps to reproduce:
-------------------
1. Build CGI script (see below cgi script)
2. Restart Apache.
3. Point a browser at the CGI script. 
4. Monitor system free memory using 'free' and apache processes using
'ps'. Over a period of 10 minutes you'll witness free memory going down
and apache thread memory going up.

1. cgi script:
------------------------
#include <time.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

/*
main.
*/
int main(int argc, char *argv[])
{
    runPlain();
}

/*
Run a text/plain test.
*/
int runPlain()
{
    int i,j;
    printf("Content-type: text/plain; charset=us-ascii\n\n");
    for (i=0; ; i++)
    {
        for (j=0; j<5; j++)
        {
            printf("%d,%d: wakka wakka wakka wakka wakka wakka
wakka\n",i,j);
        }
        printf("\n");
        usleep(5000);
    }
}



Mime
View raw message