찾다
백엔드 개발PHP7FPM의 잘 알려지지 않은 세 가지 모드

우리는 php-fpm을 자주 사용하지만, fpm에 세 가지 모드가 있다는 사실을 모두가 아는 것은 아닙니다. 오늘 Xiaonian은 필요한 경우 참조할 수 있도록 fpm의 세 가지 모드를 안내합니다.

FPM의 잘 알려지지 않은 세 가지 모드

; Choose how the process manager will control the number of child processes.
; Possible Values:
;   static  - a fixed number (pm.max_children) of child processes;
;   dynamic - the number of child processes are set dynamically based on the
;             following directives. With this process management, there will be
;             always at least 1 children.
;             pm.max_children      - the maximum number of children that can
;                                    be alive at the same time.
;             pm.start_servers     - the number of children created on startup.
;             pm.min_spare_servers - the minimum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is less than this
;                                    number then some children will be created.
;             pm.max_spare_servers - the maximum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is greater than this
;                                    number then some children will be killed.
;  ondemand - no children are created at startup. Children will be forked when
;             new requests will connect. The following parameter are used:
;             pm.max_children           - the maximum number of children that
;                                         can be alive at the same time.
;             pm.process_idle_timeout   - The number of seconds after which
;                                         an idle process will be killed.
; Note: This value is mandatory.

pm에는 정적, 동적 및 ondemand의 세 가지 모드가 있습니다.

static

이 방법은 시작 시 비교적 간단합니다. 마스터는 pm.max_children 구성에 따라 해당 수의 작업자 프로세스를 분기합니다. 즉, 작업자 프로세스 수가 고정되어 있습니다.

dynamic

동적 프로세스 관리, 먼저 fpm이 시작될 때 pm.start_servers에 따라 특정 수의 작업자를 초기화합니다.

작업 중에 마스터가 유휴 작업자 수가 구성된 pm.min_spare_servers 수보다 적음을 발견하면(요청이 너무 많아 작업자가 이를 처리할 수 없음을 나타냄) 작업자 프로세스를 포크하지만 총 작업자 수는 pm.max_children을 초과할 수 없습니다.

마스터가 유휴 작업자 수가 pm.max_spare_servers를 초과하는 것을 발견하면(유휴 작업자가 너무 많다는 것을 나타냄) 너무 많은 리소스를 점유하지 않도록 일부 작업자를 종료합니다. 마스터는 이 4가지 값을 통해 작업자 수를 제어합니다. .

ondemand

이 방법은 일반적으로 시작 시 작업자 프로세스가 할당되지 않습니다. 마스터 프로세스는 요청이 있는 후 작업자 프로세스를 포크하도록 알림을 받습니다. 이후에는 총 작업자 수가 pm.max_children을 초과하지 않습니다. 처리가 완료되면 작업자 프로세스는 즉시 종료되고 유휴 시간이 pm.process_idle_timeout을 초과하면 종료됩니다.

pm.max_children: 정적 모드에서 시작된 php-fpm 프로세스 수.

pm.start_servers: 동적 모드에서 시작하는 php-fpm 프로세스 수.

pm.min_spare_servers: 동적 모드의 최소 php-fpm 프로세스 수.

pm.max_spare_servers: 동적 모드의 최대 php-fpm 프로세스 수입니다.

FPM 신호 처리

php-fpm reloadphp-fpm reload

php-fpm stop

kill SIGUSR1 php-fpm 重新使用新的文件,完成日志切割

kill SIGUSR2 php-fpm 重新启动work进程,重新加载配置文件

Q1:启动php-fpm进程之后,kill php-fpm master进程号,还能继续服务吗? A: 不能 (所有php-fpm进程都被关闭)

Q2:启动php-fpm进程之后,kill -9 php-fpm master进程号,还能继续服务吗? A: 能(只kill了 master进程,work进程还在工作)

Q2:启动php-fpm进程之后,kill php-fpm work进程号,还能继续服务吗?A: 能(work进程被kill后,又新起一个work进程)

FPM的生命周期

php_module_startup()

fcgi_accept_request()

php_request_startup()

fmp_request_executing()

php_execute_script()

fpm_requset_end()

php_request_shutdown()

因为fpm是常驻进程,所以在php_request_shutdown()之后又会从fcgi_accept_request()

php-fpm stop

kill SIGUSR1 php-fpm 재사용 새 파일, 로그 자르기 완료kill SIGUSR2 php-fpm 작업 프로세스를 다시 시작하고 구성 파일을 다시 로드합니다

🎜Q1: php-fpm 프로세스를 시작한 후 php-fpm 마스터 프로세스 번호를 종료하고 반환할 수 있습니다. 서비스는 계속되나요? A: 아니요(모든 php-fpm 프로세스가 종료됩니다.)🎜🎜Q2: php-fpm 프로세스를 시작한 후 kill -9 php-fpm 마스터 프로세스 번호, 서비스를 계속할 수 있나요? A: 예(마스터 프로세스만 종료되고 작업 프로세스는 계속 작동 중입니다.) 🎜🎜Q2: php-fpm 프로세스를 시작한 후 php-fpm 작업 프로세스 번호를 종료합니다. 서비스를 계속할 수 있나요? A: 예(작업 프로세스가 종료된 후 새로운 작업 프로세스가 시작됩니다)🎜🎜FPM의 라이프 사이클🎜🎜🎜php_module_startup()🎜🎜fcgi_accept_request()🎜 🎜 php_request_startup()🎜🎜fmp_request_executing()🎜🎜php_execute_script()🎜🎜fpm_requset_end()🎜🎜php_request_shutdown()🎜🎜fpm은 상주 프로세스이기 때문에 루프는 php_request_shutdown() 이후 fcgi_accept_request()에서 시작됩니다. 🎜🎜🎜추천 학습: 🎜php 비디오 튜토리얼🎜🎜

위 내용은 FPM의 잘 알려지지 않은 세 가지 모드의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명
이 기사는 CSDN에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
4 몇 주 전By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
1 몇 달 전By尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

PhpStorm 맥 버전

PhpStorm 맥 버전

최신(2018.2.1) 전문 PHP 통합 개발 도구

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

Dreamweaver Mac版

Dreamweaver Mac版

시각적 웹 개발 도구