Plack::Middleware::SizeLimit - Terminate processes if they grow too large
use Plack::Builder; builder { enable SizeLimit => ( max_unshared_size_in_kb => '4096', # 4MB # min_shared_size_in_kb => '8192', # 8MB # max_process_size_in_kb => '16384', # 16MB check_every_n_requests => 2 ); $app; };
This middleware is a port of the excellent Apache::SizeLimit module for multi-process Plack servers, such as Starman, Starlet and uWSGI.
uWSGI
This middleware only works when the environment psgix.harakiri is set to a true value by the Plack server. If it's set to false, then this middleware simply does nothing.
psgix.harakiri
You must use at least version 0.2006 of Starman, and 0.19 of Starlet. Earlier versions ignore the flag to stop the process.
The maximum amount of unshared memory the process can use; usually this option is all one needs.
Experience on one heavily trafficked mod_perl site showed that setting this option 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.
Sets the minimum amount of shared memory the process must have.
The maximum size of the process, including both shared and unshared memory.
Since checking the process size can take a few system calls on some platforms (e.g. linux), you may specify this option to check the process size every N requests.
When true, a warning will be logged when it kills off a process.
Starman, Starlet
唐鳳 <cpan@audreyt.org>
To the extent possible under law, 唐鳳 has waived all copyright and related or neighboring rights to Plack::Middleware::SizeLimit.
This work is published from Taiwan.
http://creativecommons.org/publicdomain/zero/1.0
To install Plack::Middleware::SizeLimit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::SizeLimit
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::SizeLimit
For more information on module installation, please visit the detailed CPAN module installation guide.