perl-docs-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r109986 - /perl/modperl/docs/trunk/src/docs/2.0/api/Apache/SizeLimit.pod /perl/modperl/docs/trunk/src/docs/2.0/api/config.cfg
Date Mon, 06 Dec 2004 16:35:42 GMT
Author: stas
Date: Mon Dec  6 08:35:40 2004
New Revision: 109986

URL: http://svn.apache.org/viewcvs?view=rev&rev=109986
Log:
perrin has ported Apache::SizeLimit

Added:
   perl/modperl/docs/trunk/src/docs/2.0/api/Apache/SizeLimit.pod
Modified:
   perl/modperl/docs/trunk/src/docs/2.0/api/config.cfg

Added: perl/modperl/docs/trunk/src/docs/2.0/api/Apache/SizeLimit.pod
Url: http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/api/Apache/SizeLimit.pod?view=auto&rev=109986
==============================================================================
--- (empty file)
+++ perl/modperl/docs/trunk/src/docs/2.0/api/Apache/SizeLimit.pod	Mon Dec  6 08:35:40 2004
@@ -0,0 +1,172 @@
+=head1 NAME
+
+Apache::SizeLimit - Because size does matter.
+
+=head1 Synopsis
+
+This module allows you to kill off Apache httpd processes if they grow
+too large.  You can choose to set up the process size limiter to check
+the process size on every request:
+
+  # in your startup.pl, or a <Perl> section:
+  use Apache::SizeLimit;
+  # sizes are in KB
+  $Apache::SizeLimit::MAX_PROCESS_SIZE  = 12000; # 12MB
+  $Apache::SizeLimit::MIN_SHARE_SIZE    = 6000;  # 6MB
+  $Apache::SizeLimit::MAX_UNSHARED_SIZE = 5000;  # 5MB
+
+  # in your httpd.conf:
+  PerlCleanupHandler Apache::SizeLimit
+
+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 scripts under C<ModPerl::Registry>:
+
+  # in your script:
+  use Apache::SizeLimit;
+  # sizes are in KB
+  Apache::SizeLimit::setmax(12000);
+  Apache::SizeLimit::setmin(6000);
+  Apache::SizeLimit::setmax_unshared(5000);
+
+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.
+
+=head1 Description
+
+This module is highly platform dependent, please read the
+L<CAVEATS|/Caveats> section.  It also does not work under threaded
+MPMs, as explained below.
+
+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 system starts swapping.  Second, it may just
+do things that requires a lot of memory, and the more different kinds
+of requests your server handles, the larger the httpd processes grow
+over time.
+
+This module will not really help you with the first problem.  For that
+you should probably look into Apache::Resource or some other means of
+setting a limit on the data size of your program.  BSD-ish systems
+have setrlimit() 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 B<MaxRequestsPerChild>, although you
+can use both if you are feeling paranoid.  Personally, I just use the
+technique shown in this module and set my MaxRequestsPerChild value to
+0.
+
+=head1 Shared Memory Options
+
+In addition to simply checking the total size of a process, this
+module can factor in how much of the memory used by the process is
+actually being shared by copy-on-write.  If you don't understand how
+memory is shared in this way, take a look at the extensive
+documentation at http://perl.apache.org/.
+
+You can take advantage of the shared memory information by setting a
+minimum shared size and/or a maximum unshared size.  Experience on one
+heavily trafficked mod_perl site showed that setting maximum unshared
+size and leaving the others unset is the most effective policy.  This
+is because it only kills off processes that are truly using too much
+physical RAM, allowing most processes to live longer and reducing the
+process churn rate.
+
+=head1 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.  In particular, the limits on minimum shared memory and
+maximum shared memory are currently only supported on Linux and BSD.
+If you can contribute support for another OS, please do.
+
+Currently supported OSes:
+
+=over 4
+
+=item linux
+
+For linux we read the process size out of /proc/self/status.  This
+seems to be fast enough on modern systems. If you are worried about
+performance, try setting the CHECK_EVERY_N_REQUESTS option.
+
+=item 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.
+Shared memory calculations are not supported.
+
+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?
+
+=item *BSD*
+
+Uses BSD::Resource::getrusage() to determine process size.  This is
+pretty efficient (a lot more efficient than reading it from the /proc
+fs anyway).
+
+=item AIX?
+
+Uses BSD::Resource::getrusage() to determine process size.  Not sure
+if the shared memory calculations will work or not.  AIX users?
+
+=item Win32
+
+Uses Win32::API to access process memory information.  Win32::API can
+be installed under ActiveState perl using the supplied ppm utility.
+
+=back
+
+If your platform is not supported, and if you can tell me how to check
+for the size of a process under your OS (in KB), then I will add it to
+the list.  The more portable/efficient the solution, the better, of
+course.
+
+
+
+
+=head1 Threaded MPMs
+
+At this time, Apache::SizeLimit does not support use under threaded
+MPMs, including "worker."  This is because there is no efficient way
+to get the memory usage of a thread, or make a thread exit cleanly.
+Suggestions and patches are welcome on the mod_perl dev mailing list.
+
+
+
+=head1 Copyright
+
+mod_perl 2.0 and its core modules are copyrighted under
+The Apache Software License, Version 2.0.
+
+
+=head1 Author
+
+Doug Bagley <doug+modperl bagley.org>, channeling Procrustes.
+
+Brian Moseley <ix maz.org>: Solaris 2.6 support
+
+Doug Steinwand and Perrin Harkins <perrin elem.com>: added support for
+shared memory and additional diagnostic info
+
+Matt Phillips <mphillips virage.com> and Mohamed Hendawi
+<mhendawi virage.com>: Win32 support
+
+=cut

Modified: perl/modperl/docs/trunk/src/docs/2.0/api/config.cfg
Url: http://svn.apache.org/viewcvs/perl/modperl/docs/trunk/src/docs/2.0/api/config.cfg?view=diff&rev=109986&p1=perl/modperl/docs/trunk/src/docs/2.0/api/config.cfg&r1=109985&p2=perl/modperl/docs/trunk/src/docs/2.0/api/config.cfg&r2=109986
==============================================================================
--- perl/modperl/docs/trunk/src/docs/2.0/api/config.cfg	(original)
+++ perl/modperl/docs/trunk/src/docs/2.0/api/config.cfg	Mon Dec  6 08:35:40 2004
@@ -34,7 +34,6 @@
         Apache/RequestIO.pod
         Apache/RequestRec.pod
         Apache/RequestUtil.pod
-        Apache/Resource.pod
         Apache/Response.pod
         Apache/ServerRec.pod
         Apache/ServerUtil.pod
@@ -87,7 +86,9 @@
         Apache/compat.pod
         Apache/porting.pod
         Apache/Reload.pod
+        Apache/Resource.pod
         Apache/Status.pod
+        Apache/SizeLimit.pod
     )],
 
     group    => 'Internal Modules',

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: docs-cvs-help@perl.apache.org


Mime
View raw message