php / php/php-src

PHP_FCGI_MAX_IDLE_TIMEOUT environment variabile option for php-cgi

Open
#13,533 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature SAPI: cgi
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

I'm writing an "external" multiplatform php fastcgi process manager in golang for the caddy webserver, something like php-fpm but using the php-cgi executable in fastcgi mode;

while implementing it using socket passing to be faster simpler and have zero-copy between processes

i've found that i wanted to add an option in my process manager analogous to php-fpm pm.process_idle_timeout to free memory when the server load is low and to avoid eventual memory leaks

I've thinked about how to implement this feature for a while in a way that does not require modifying php-cgi itself, but without finding a solution that allowed to keeping zero-copy socket passing.

The proposal is to add an environment variabile option that instruct php-cgi processes to self terminate after a certain amount of time if no requests are received, something like the already existing PHP_FCGI_MAX_REQUESTS that already aligns with php-fpm pm.max_requests.

Eventually having millisecond granularity unlike second granularity only like in pm.process_idle_timeout will be a plus.

That Is... Hoping i'm not missing something obviuos and that the proposal make sense.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the php-cgi FastCGI process lifecycle and the existing PHP_FCGI_MAX_REQUESTS option, since no source file or test is named. Define how an idle timeout should be configured and measured, then add coverage showing that an idle process terminates while a process receiving requests remains active.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.