FCGI::...quests(3pm)

πŸ“¦
version 0.2 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

🌸 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_REQUESTS environment variable 🌈
  • the max_requests constructor argument
  • the max_requests accessor

✨ 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 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