|


| NAVIGATION |
|
Home |
|
Store |
|
|
| INSIDE MAC |
|
Television Shows |
|
Broadcast Shows |
|
Daily News Shows |
|
Special Shows |
|
|
| EVENTS |
|
|
|
|
|
|
|
|
| DAILY TIPS |
|
Design |
|
Mac OS X |
|
Mac OS X UNIX |
|
|
| COMMUNITY |
|
Surveys |
|
|
| NEWS |
|
Current |
|
Press |
|
Archive |
|
|
| FEATURES |
|
Editorial |
|
Dr. Mac |
|
Reviews |
|
Reader Reports |
|
|
| RESOURCES |
|
FAQ |
|
Documentation |
|
Learning Center |
|
MAN pages |
|
Glossary |
|
Tutorials |
|
Tips |
|
Links |
|
|
|

|
|
|
Apache::SizeLimit - Because size does matter.
SYNOPSIS
This module allows you to kill off Apache httpd processes
if they grow too large. You can choose to set up the pro-
cess size limiter to check the process size on every
request:
# in your startup.pl:
use Apache::SizeLimit;
$Apache::SizeLimit::MAX_PROCESS_SIZE = 10000; # in KB, so this is 10MB
# in your httpd.conf:
PerlFixupHandler Apache::SizeLimit
# you can set this up as any Perl*Handler that handles part of the
# request, even the LogHandler will do.
Or you can just check those requests that are likely to
get big, such as CGI requests. This way of checking is
also easier for those who are mostly just running
CGI.pm/Registry scripts:
# in your CGI:
use Apache::SizeLimit;
&Apache::SizeLimit::setmax(10000); # Max Process Size in KB
Since checking the process size can take a few system
calls on some platforms (e.g. linux), you may want to only
check the process size every N times. To do so, put this
in your startup.pl or CGI:
$Apache::SizeLimit::CHECK_EVERY_N_REQUESTS = 2;
This will only check the process size every other time the
process size checker is called.
DESCRIPTION
This module is highly platform dependent, please read the
CAVEATS section.
This module was written in response to questions on the
mod_perl mailing list on how to tell the httpd process to
exit if it gets too big.
Actually there are two big reasons your httpd children
will grow. First, it could have a bug that causes the
process to increase in size dramatically, until your sys-
tem starts swapping. Second, your process just does stuff
that requires a lot of memory, and the more different
kinds of requests your server handles, the larger the
httpd processes grow over time.
Apache::Resource or some other means of setting a limit on
the data size of your program. BSD-ish systems have setr-
limit() which will croak your memory gobbling processes.
However it is a little violent, terminating your process
in mid-request.
This module attempts to solve the second situation where
your process slowly grows over time. The idea is to check
the memory usage after every request, and if it exceeds a
threshold, exit gracefully.
By using this module, you should be able to discontinue
using the Apache configuration directive MaxRequestsPer-
Child, although for some folks, using both in combination
does the job. Personally, I just use the technique shown
in this module and set my MaxRequestsPerChild value to
6000.
CAVEATS
This module is platform dependent, since finding the size
of a process is pretty different from OS to OS, and some
platforms may not be supported.
Currently supported OSes:
linux
For linux we read the process size out of
/proc/self/status. This is a little slow, but usually
not too bad. If you are worried about performance, try
only setting up the the exit handler inside CGIs (with
the `setmax' function), and see if the
CHECK_EVERY_N_REQUESTS option is of benefit.
solaris 2.6 and above
For solaris we simply retrieve the size of
/proc/self/as, which contains the address-space image
of the process, and convert to KB.
NOTE: This is only known to work for solaris 2.6 and
above. Evidently the /proc filesystem has changed
between 2.5.1 and 2.6. Can anyone confirm or deny?
*bsd*
Uses BSD:\fIs0:Resource::getrusage() to determine pro-
cess size. This is pretty efficient (a lot more effi-
cient than reading it from the /proc fs anyway).
AIX?
Uses BSD:\fIs0:Resource::getrusage() to determine pro-
cess size.
If your platform is not supported, and if you can tell me
portable/efficient the solution, the better, of course.
TODO
Possibly provide a perl make/install so that the Size-
Limit.pm is created at build time with only the code you
need on your platform.
If Apache was started in non-forking mode, should hitting
the size limit cause the process to exit?
AUTHOR
Doug Bagley <doug+modperl@bagley.org>, channeling Pro-
crustes.
Brian Moseley <ix@maz.org>: Solaris 2.6 support
|


|
Copyright © 2000-2010 Inside Mac Media, Inc. All rights reserved. |
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users. |
| Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc. |
|