You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Christoph Bergmann <in...@java.seite.net> on 2002/01/09 17:35:35 UTC

BSD::Resource und apache/mod_perl

hi...

I use BSD::Resource to limit the RAM a mod_perl process could get. this
works perfectly right on one machine but on another the process does not
get any RAM at all and is killed immediately. both servers run under
linux and therefor I use RLIMIT_AS as described in the "mod_perl guide"
from stas bekman:
http://thingy.kcilink.com/modperlguide/performance/OS_Specific_notes.html

The following test script works as it should if it runs from the shell
(means: it runs a while, then it stops with "Out of memory error!"):


#!/usr/bin/perl

print "Content-type: text/html\n\ntest...";

use BSD::Resource;
setrlimit RLIMIT_AS, 32000000, 64000000;

for($i=0; $i<6000000; $i++)
{
	$a.="dsafadsfadsfadfhakdhfkjaf";
}
print "ok";


but it stops IMMEDIATELY with "out of memory"/"document contains no
data" if called via browser from apache/mod_perl. (it has nothing to do
with "forecasting": if the loop iterations are set lower (i.g. to 1) the
script should give "test...ok" but it stops immediately with "out of
memory" as well)


has anybody any ideas?


thanx in advance, best regards,


christoph bergmann


Re: BSD::Resource und apache/mod_perl

Posted by Christoph Bergmann <in...@java.seite.net>.
Perrin Harkins wrote:
> 
> The difference is that Apache::Resource should apply this limit to each
> new child process.  When you do this from the shell, you are limiting
> the parent Apache process, which isn't very useful.

I put

use BSD::Resource;
setrlimit RLIMIT_AS, 32000000, 64000000;

at the top of the script which should be limited. So only the Apache
child process of this script is limited.

> 
> Are you sure you're using the right units (bytes vs. megabytes)?  Could

Yes, "setrlimit" wants bytes, Apache::Resource wants MBytes.

> your server be immediately going higher than the limit you set for it?

Mmh, but what could be the reason? A normal httpd process has i.g. 8 MB
and i set the limit to 32 MB. If I run the test script without
"setrlimit" and watch it with top it slowly consumes the RAM appr. 1 MB
/ sec...


Anyway: I still don't know what the reason was for this problem -  but I
solved it with installing a brand new apache, perl & mod_perl - now it
works as it should! ;-)

Thanx for your help nonetheless!!


> 
> - Perrin


Best regards,

Christoph


Re: BSD::Resource und apache/mod_perl

Posted by Perrin Harkins <pe...@elem.com>.
> PerlModule Apache::Resource
> PerlSetEnv PERL_RLIMIT_AS 32:64
> PerlChildInitHandler Apache::Resource
>
> in httpd.conf, but Apache::Resource uses BSD::Resource in the end and
> thus its the same as
>
> use BSD::Resource;
> setrlimit RLIMIT_AS, 32000000, 64000000;

The difference is that Apache::Resource should apply this limit to each
new child process.  When you do this from the shell, you are limiting
the parent Apache process, which isn't very useful.

Are you sure you're using the right units (bytes vs. megabytes)?  Could
your server be immediately going higher than the limit you set for it?

- Perrin


Re: BSD::Resource und apache/mod_perl

Posted by Christoph Bergmann <in...@java.seite.net>.
Thanx, but that leads to the same result. In the first place I used:

PerlModule Apache::Resource
PerlSetEnv PERL_RLIMIT_AS 32:64
PerlChildInitHandler Apache::Resource

in httpd.conf, but Apache::Resource uses BSD::Resource in the end and
thus its the same as

use BSD::Resource;
setrlimit RLIMIT_AS, 32000000, 64000000;

at top of the test script. I use "setrlimit" directly so I could test if
BSD::Resource works at all - and it DOES if run from the shell - but it
does NOT if run from Apache/mod_perl.....

What could cause the different behaviour??

Best regards,

Christoph Bergmann


Perrin Harkins wrote:
> 
> > has anybody any ideas?
> 
> Apache::Resource.


Re: BSD::Resource und apache/mod_perl

Posted by Perrin Harkins <pe...@elem.com>.
> has anybody any ideas?

Apache::Resource.