homepage Welcome to WebmasterWorld Guest from 54.196.201.253
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
FreeBSD 4.10 + Apache 2.0.5x: Using limits/ulimit
How to use (u)limit on Apache 2 process
Orange_XL




msg:913045
 3:54 pm on Feb 9, 2005 (gmt 0)

On FreeBSD, you can set the limits (ulimit) through a variable (apache2limits_args enabled by apache2limits_enable) in rc.conf. If enabled, it uses the limits for login-class daemon as found in /etc/login.class;

daemon:\
:coredumpsize@:\
:coredumpsize-cur=0:\
:datasize=infinity:\
:datasize-cur@:\
:maxproc=512:\
:maxproc-cur@:\
:memoryuse-cur=64M:\
:memorylocked-cur=64M:\
:openfiles=1024:\
:openfiles-cur@:\
:stacksize=16M:\
:stacksize-cur@:\
:tc=default:

I take it these settings are quite general, and may not be sufficient (to restrictive or not). So I was wondering what kind of limits other users are using (set the FreeBSD way or using something like ulimit on other platforms). And how those settings scale or depend on various configurations?

Googling, or Apache: Definitive Reference / Apache Cookbook do not seem to provide any clues here :-(

 

jollymcfats




msg:913046
 4:52 pm on Feb 9, 2005 (gmt 0)

This is the sort of thing that is totally dependent on what you're serving and what your goals are for the limits. Every apache module will increase the amount of memory and possibly the # of open files; dynamic content will increase these even more, and the numbers will climb the longer the child process survives.

If your goal with limits is to protect against run-away processes or guard somewhat against intrusion, spend some quality time taking measurements with top and lsof to find out the normal bounds for your site. Then you can pick tailored limits. But remember that when the child process hits a limit it will die. Fine if there is a problem, not so good if it is serving a legitimite request.

Orange_XL




msg:913047
 7:04 pm on Feb 9, 2005 (gmt 0)

This is the sort of thing that is totally dependent on what you're serving and what your goals are for the limits. Every apache module will increase the amount of memory and possibly the # of open files; dynamic content will increase these even more, and the numbers will climb the longer the child process survives.

I know, but I cannot always put numbers on those items. And I don't see such numbers anywhere.


If your goal with limits is to protect against run-away processes or guard somewhat against intrusion, spend some quality time taking measurements with top and lsof to find out the normal bounds for your site. Then you can pick tailored limits. But remember that when the child process hits a limit it will die. Fine if there is a problem, not so good if it is serving a legitimite request.

It is bascially because I recently installed mod_php. And since someone start using it, everything is falling apart :-( Server hangs on some occasions, and I get really weird memory errors (it seems that something is eating up all mem, crashing the box at some point). It only seems to happen with certain scripts.

So, besides solving the problem, I also want some protection against the impact of such scripts. Limits seem a good idea, but as far as I can find, fairly undocumented. So, that's the reason I'm asking here :-)

Beside's thing like top, ps, lsof, what other programs can I use? For instance, to configure maxproc?

jollymcfats




msg:913048
 1:58 am on Feb 10, 2005 (gmt 0)

I know, but I cannot always put numbers on those items. And I don't see such numbers anywhere.

Your resource usage is pretty specific to your OS version, Apache build, configuration and work load. Last time I was involved in a big ulimiting, we gathered data on our systems for a week or two before we tried any limits. Even after that we had to continue tuning.

So, besides solving the problem, I also want some protection against the impact of [PHP] scripts.

PHP itself has built-in memory limiting. (php.ini: memory_limit) Tweaking that is a lot less intrusive than ulimiting the entire daemon. You might also get some mileage out of safe mode.

Beside's thing like top, ps, lsof, what other programs can I use? For instance, to configure maxproc?

Setting maxproc is probably the most straightforward. You can set it to the max # of apache children, plus one, plus the number of sub-shells any child may have running at once. Actually the last calculation is less straightforward, because you need to find out if and how often your user's CGIs and PHP scripts spawn child processes.

Orange_XL




msg:913049
 2:33 pm on Feb 11, 2005 (gmt 0)

PHP itself has built-in memory limiting. (php.ini: memory_limit) Tweaking that is a lot less intrusive than ulimiting the entire daemon. You might also get some mileage out of safe mode.

While PHP respects the limit, Apache 2 seems to have difficulties with it. Ever since I started using PHP, I've getting Memory-errors for cgi :-¦ Problem seems to be caused by some php-scripts that use POST, but I have no clue why.

Setting maxproc is probably the most straightforward. You can set it to the max # of apache children, plus one, plus the number of sub-shells any child may have running at once. Actually the last calculation is less straightforward, because you need to find out if and how often your user's CGIs and PHP scripts spawn child processes.

Indeed that last one gave me a bit of trouble, as some CGI really seem to spawn a lot of children.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved