FCGI::...quests(3pm)
πΈ FCGI::ProcManager::MaxRequests π
okay bestie, you know how a FastCGI worker just keeps going and going and never, ever stops, and its memory just grows and grows like a group chat you never muted? yeah. this is the module that tells each kid "you get 100 requests and then you're DONE, go take a nap, we'll spawn a fresh one." it lives in the User Contributed Perl Documentation corner of your 3pm man pages, and it's giving responsible parent energy. π«Ά
β¨ NAME β¨
FCGI::ProcManager::MaxRequests β restrict max number of requests by each child π₯
β¨ SYNOPSIS β¨
Usage is literally the same as FCGI::ProcManager, no cap:
use CGI::Fast;
use FCGI::ProcManager::MaxRequests;
my $m = FCGI::ProcManager::MaxRequests->new({
n_processes => 10,
max_requests => 100,
});
$m->manage;
while( my $cgi = CGI::Fast->new() ) {
$m->pm_pre_dispatch();
...
$m->pm_post_dispatch();
}
β¨ DESCRIPTION β¨
so FCGI-ProcManager-MaxRequests is an extension of FCGI-ProcManager that lets you restrict your fastcgi processes to process only a limited number of requests. π« the whole point? it helps avoid memory usage growing forever, and it compensates for memory leaks. iconic behaviour honestly.
this module subclasses FCGI::ProcManager. after a server process handles max_requests number of requests, it simply exits, and the manager spins up another server process. new kid, same job. π§
the maximum number of requests can be set from three places, and you have options:
- the
PM_MAX_REQUESTSenvironment variable π - the
max_requestsconstructor argument - the
max_requestsaccessor
β¨ OVERLOADED METHODS β¨
π new
my $pm = FCGI::ProcManager::MaxRequests->new(\%args);
constructs a new proc manager object. β¨ that's it, that's the job.
π max_requests
$pm->max_requests($max_requests);
my $max_requests = $pm->max_requests;
set/get the current max_requests value. π
getter-setter combo, we love a two-for-one.
π handling_init
initialize the requests counter after the new worker process forks. π important timing bestie, after the fork.
π pm_post_dispatch
this one does all the work. π it decrements the requests counter after each request, and exits the worker when needed. the actual bouncer of this whole operation.
β¨ USING WITH CATALYST β¨
ngl, at this time Catalyst::Engine::FastCGI does not allow setting any args to the FCGI::ProcManager subclass constructor. π so because of that, we should use the environment variable PM_MAX_REQUESTS ;-) (the original author put that winky face there, and honestly? valid.)
PM_MAX_REQUESTS=100 ./script/myapp_fastcgi.pl -n 10 -l <host>:<port> -d -M FCGI::ProcManager::MaxRequests
β¨ SEE ALSO β¨
you can also see FCGI::Spawn, but heads up β it doesn't support TCP sockets and it tries to use CGI::Fast... so, you know. π
β¨ AUTHOR β¨
Vladimir Timofeev, <vovkasm at gmail.com> π
β¨ BUGS β¨
please report any bugs or feature requests to bug-fcgi-procmanager-maxrequests at rt.cpan.org, or through the web interface at:
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=FCGI-ProcManager-MaxRequests>
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. π closed loop communication, we stan.
β¨ SUPPORT β¨
you can find documentation for this module with the perldoc command:
perldoc FCGI::ProcManager::MaxRequests
you can also look for information at:
- RT: CPAN's request tracker
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=FCGI-ProcManager-MaxRequests>
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/FCGI-ProcManager-MaxRequests>
- CPAN Ratings
<http://cpanratings.perl.org/d/FCGI-ProcManager-MaxRequests>
- Search CPAN
<http://search.cpan.org/dist/FCGI-ProcManager-MaxRequests/>
- Source code repository
<http://svn.vovkasm.org/FCGI-ProcManager-MaxRequests>
β¨ ACKNOWLEDGEMENTS β¨
(no cap, this section is genuinely empty in the original. bestie left it blank. we're respecting the blankness. π³οΈβ¨)
β¨ COPYRIGHT & LICENSE β¨
Copyright 2008 Vladimir Timofeev.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie π this one's from perl v5.32.0, dated 2021-01-09, filed under FCGI::...quests(3pm) β yes the title got truncated, the man page header did that, not me. go forth and cap your workers. periodt. π
π¦ where this page comes from
- debian bookworm: libfcgi-procmanager-maxrequests-perl 0.2-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libfcgi-procmanager-maxrequests-perl 0.2-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libfcgi-procmanager-maxrequests-perl 0.2-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libfcgi-procmanager-maxrequests-perl 0.2-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libfcgi-procmanager-maxrequests-perl 0.2-1.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms