- FPM (FastCGI Process Manager )

    - php-cgi.exe가 자꾸 에러가 나서 크래쉬 되며 다운될때 

    - windows php-cgi.exe crash too often

 

    - 환경

    windows 10,  nginx v1.17.4 , php v7.3.22



//-----------------

    - OS 환경변수 

 

PHP_FCGI_CHILDREN

    - 동시에 실행할 fpm(php-cgi.exe)프로세스 개수, 기본은 1

 

PHP_FCGI_MAX_REQUESTS 

    - 몇개의 요청을 처리후 종료할지 지정, 메모리 누수 현상 대비, 

    - 기본은 0 이라는데 윈도우에서는 500 정도 인듯하다

        - 그래서 500개 정도의 요청을 처리후 php-cgi.exe가 종료됨



    //--------------------------------

    - nginx 실행 bat 파일 첫 부분에 다음을 추가

 

set PHP_FCGI_CHILDREN=5

set PHP_FCGI_MAX_REQUESTS=10000



//-----------------------------------------------------------------------------

nginx.conf 설정

 

# nginx 프로세스 수
worker_processes  5;


events {

    # 1개 프로세스가 처리하는 최대 접속 수
    worker_connections  200;
}

 

 

//-----------------------------------------------------------------------------

// 참고

php-cgi.exe quits after exactly 500 hits

https://stackoverflow.com/questions/12487147/php-cgi-exe-quits-after-exactly-500-hits/34458348



https://www.php.net/manual/en/install.fpm.configuration.php

 

PHP_FCGI_MAX_REQUESTS

pm.max_requests int

    The number of requests each child process should execute before respawning. This can be useful to work around memory leaks in 3rd party libraries. For endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. Default value: 0.




PHP_FCGI_CHILDREN

pm.max_children int

    The number of child processes to be created when pm is set to static and the maximum number of child processes to be created when pm is set to dynamic. This option is mandatory.

    This option sets the limit on the number of simultaneous requests that will be served. Equivalent to the ApacheMaxClients directive with mpm_prefork and to the PHP_FCGI_CHILDREN environment variable in the original PHP FastCGI.



반응형
Posted by codens