httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Manik Taneja <mtan...@movik.net>
Subject Re: Memory leak in mod_proxy_http and in mpm_event components.
Date Wed, 22 Oct 2008 15:05:48 GMT
To give you a bit of a background. We have configured apache as a 
forward proxy and that is front-ended by another lightweight proxy 
load-balancer. We want to keep a connection between the load-balancer 
and apache open for as long as possible. Therefore we set the keep-alive 
idle timeout on apache to about 900 seconds and MaxKeepAlive requests 
should be ideally set to 0. Now we found that apache continues to 
consume memory at fairly constant rate, this happens when all caching, 
mod_mem_cache and mod_disk_cache are turned off.

Take a look at the attached graphs, that demonstrates the memory growth 
over a period of time for the following scenarios:

1. 2 GB cache size, small size objects so the cache never got full 
throughout the polygraph run.
2. Limited size cache, 300 objects. To simulate a mix of cache 
replacements and cache hits.
3. All objects uncacheable
4. Cache disabled
5. Cache disabled. mpm=worker
6. Cache disabled. Server keep-alive = off
7. Cache enabled. 600megs, Keep-alive = off

To summarize :

Memory keeps getting allocated endlessly even when the caching is turned 
off. The culprit is the keepAlive setting on the Apache server. As long 
as the keep-alive is "On" memory is not getting freed, the moment that 
setting is switched to "off", after a certain point in the run the 
memory usage reaches a peak value and stabilizes. Even though there is a 
significant overhead per object when caching is turned, but at least 
that is bounded and that could be looked at later.

I also observed that when idle keep-alive connections are closed by 
apache, the memory usage doesn't drop. So this indicates that memory 
pool cleanups are not being called from whatever mechanism that apache 
uses to cleanup idle connections.

It is possible to constrain the amount of memory used, if the 
MaxKeepAlive requests is set to a positive value, such as 500 or so. In 
that case a leak is still observed but the rate of memory growth is much 
slower.

With regards to the patch, it seems that the changes in event.c have no 
effect. We have anyway seen the leak with both worker and event mpm. The 
changes in scoreboard.c just ensure that memory pointed to by new_sbh is 
not lost everytime ap_create_sb_handle is called.

I have tested this fix and the memory consumption has dropped 
drastically, however I still do observe a slow leak at times. I haven't 
got the opportunity to spend a whole lot of time testing the fix. Its on 
my plate however, and I'll send out my findings to the group sometime 
next week.

Thanks,
Manik





Nick Kew wrote:
> On Wed, 22 Oct 2008 17:43:41 +0530
> "harish kulkarni" <wasinapple@gmail.com> wrote:
>
>   
>> Hello All,
>>
>> After spending quite some time on apache and components ( specifically
>> mod_proxy_http, mod_mem_cache etc) we have noticed some memory leaks
>> which we are publishing with attached patch.
>>     
>
> At a glance, this looks like more than one patch.  The proxy_http
> patch looks straightforward, but does the event MPM fix do anything?
> I mean, does the scoreboard allocate memory per-request within
> a connection?  And if so, how does this affect other MPMs?
>
>   


Mime
View raw message