---
name: "FCGI::ProcManager::MaxRequests"
section: "3pm"
platform: "linux"
package: "libfcgi-procmanager-maxrequests-perl"
version: "0.2-1.1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/FCGI::ProcManager::MaxRequests"
---

# FCGI::ProcManager::MaxRequests(3pm)

restrict max number of requests by each child

## NAME

FCGI::ProcManager::MaxRequests - restrict max number of requests by each child

## SYNOPSIS

Usage same as FCGI::ProcManager:

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

FCGI-ProcManager-MaxRequests is a extension of FCGI-ProcManager that allow restrict fastcgi processes to process only limiting number of requests. This may help avoid growing memory usage and compensate memory leaks.

This module subclass FCGI::ProcManager. After server process max\_requests number of requests, it simple exit, and manager starts another server process. Maximum number of requests can be set from PM\_MAX\_REQUESTS environment variable, max\_requests - constructor argument and max\_requests accessor.

## OVERLOADED METHODS

### new

```
    my $pm = FCGI::ProcManager::MaxRequests->new(\%args);
```

Constructs new proc manager object.

### max\_requests

```
    $pm->max_requests($max_requests);
    my $max_requests = $pm->max_requests;
```

Set/get current max\_requests value.

### handling\_init

Initialize requests counter after new worker process forks.

### pm\_post\_dispatch

Do all work. Decrements requests counter after each request and exit worker when needed.

## USING WITH CATALYST

At this time, Catalyst::Engine::FastCGI do not allow set any args to FCGI::ProcManager subclass constructor. Because of this we should use environment PM\_MAX\_REQUESTS ;-)

```
    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 it don't support TCP sockets and try use CGI::Fast...

## 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.

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

## 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.
