# php-cgi: cgi_main.c => max_requests = 500?

- Thread: https://externals.io/message/40073
- Original archive: https://news-web.php.net/php.internals/40073
- Started by Guido on 2008-08-24T13:51:19+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #40073 — Guido — 2008-08-24T13:51:19+00:00

URL: https://externals.io/message/40073#40073

Hi all,

I am new to PHP and to this forum.

I was testing my webserver with PHP and found out that after 500 
requests the php-cgi process finished (without cores). I ran it with 
valgrind and no memory leaks :). I thought it couldn't be a coincidence 
that, always, after 500 requests, php-cgi finished; so I have had a look 
at cgi_main.c and found:

max_requests = 500;

I have seen that the environment variable: PHP_FCGI_MAX_REQUESTS might
be used to override this value; why php-cgi has to finish after n requests?

Thanks in advance,

Guido.

---

## #40074 — Marcus Boerger — 2008-08-24T14:16:49+00:00

URL: https://externals.io/message/40073#40074 · In reply to: #40073

Hello Guido,

Sunday, August 24, 2008, 3:51:19 PM, you wrote:

> Hi all,

> I am new to PHP and to this forum.

> I was testing my webserver with PHP and found out that after 500 
> requests the php-cgi process finished (without cores). I ran it with 
> valgrind and no memory leaks :). I thought it couldn't be a coincidence 
> that, always, after 500 requests, php-cgi finished; so I have had a look 
> at cgi_main.c and found:

> max_requests = 500;

> I have seen that the environment variable: PHP_FCGI_MAX_REQUESTS might
> be used to override this value; why php-cgi has to finish after n requests?

It is a common habit to reload the binary after a given number of requests.
This prevents memory leaks and other esource issues.

Best regards,
 Marcus

---

## #40076 — Guido — 2008-08-24T16:39:38+00:00

URL: https://externals.io/message/40073#40076 · In reply to: #40074

Marcus Boerger wrote:
> Hello Guido,
> 
> Sunday, August 24, 2008, 3:51:19 PM, you wrote:
> 
> > […]
> 
> > […]
> 
> > […]
> 
> > […]
> 
> > […]
> 
> It is a common habit to reload the binary after a given number of requests.
> This prevents memory leaks and other esource issues.
> 
> Best regards,
>  Marcus
> 

Hi Marcus,

thank you very much for your response. I have set the environment 
variable to a big number and test with valgrind and everything seems to 
be fine (no leaks), so before launching php-cgi, I will always set this 
variable :).


Guido.
