当前位置:网站首页>Fastcgi operation principle and PHP FPM parameter configuration
Fastcgi operation principle and PHP FPM parameter configuration
2022-07-24 11:13:00 【Brother Xing plays with the clouds】
1、 What is? CGI
CGI The full name is “ Public gateway interface ”(Common Gateway Interface),http The server Work with programs on your or other machines “ conversation ” A tool of ,CGI The program must run on the network The server On .
Tradition CGI The main drawback of interface mode is poor performance , Because every time http The server When encountering dynamic programs, you need to restart the script parser to execute parsing , The result is then returned to http The server , When dealing with highly concurrent access , It's almost unavailable , So it was born FastCGI. And the traditional CGI The security of the interface mode is also very poor , It's rarely used now .
2、 What is? FastCGI
FastCGI It's a scalable 、 At high speed http server Interface for communication with dynamic scripting languages (FastCGI Interface in Linux Next is socket, This socket It could be a file socket, It can also be ip socket), The main advantages are dynamic language and HTTP Server Separate from . Most popular HTTP server All support FastCGI Include Nginx and Lighttpd etc. , meanwhile FastCGI Also supported by many scripting languages , Among them PHP.FastCGI The interface mode is C/S structure , Can be http Separate server and script resolution server , Start one or more script resolution daemons on the script resolution server at the same time . When http Every time the server encounters a dynamic program , It can be delivered directly to FastCGI Process to execute , Then return the result to the browser . This way we can make http The server specifically processes static requests or returns the results of the dynamic script server to the client , This greatly improves the performance of the whole application system .
3、Nginx Next FastCGI Operation principle
Nginx It does not support direct calling or parsing of external programs , All external procedures ( Include PHP) Must pass FastCGI Interface to call .FastCGI Interface in Linux Next is socket( This socket It could be a file socket, It can also be IP socket). In order to call CGI Program , I need one more FastCGI Of wrapper(wrapper It can be understood as a program used to start another program ), This wrapper Bind to a fixed socket On , Like ports or files socket. When Nginx take CGI Request sent to this socket When , adopt FastCGI Interface ,wrapper Accept the request , Then spawn a new thread , This thread calls the interpreter or external program to process the script and read the return data , next ,wrapper Then pass the returned data through FastCGI Interface , Along the fixed socket Pass to Nginx, Last Nginx Send the returned data to the client , This is it. Nginx+FastCGI The whole process of operation .
4、 Optimize php-fpm Process management configuration parameters .
php-fpm Compiler parameters for :
php5.3 And above versions, the compilation parameters are ”--enable-fpm”
php5.2 And the following version compilation parameters are ”--enable-fastcgi --enable-fpm --enable-force-cgi”
#php-fpm.conf Profile parameter optimization options .
pm.max_children = 1024 # Maximum number of subprocesses
pm.start_servers = 16 # Number of processes at startup
# Ensure that the minimum number of idle processes , If the idle process is less than this value , Create a new subprocess
pm.min_spare_servers = 5
# Maximum number of idle processes guaranteed , If the idle process is greater than this value , Then clean up
pm.max_spare_servers = 20
# Timeout for process
pm.process_idle_timeout = 15s
# Set the maximum number of requests processed by each child process
pm.max_requests = 1000
# Set the rlimit Limit
rlimit_files = 1024
# When a request for this setting timeout , It will correspond to PHP Call stack information is fully written to the slow log . Set to '0' Express 'Off'
request_slowlog_timeout = 10s
# Logging of slow requests , coordination request_slowlog_timeout Use
slowlog = log/$pool.log.slow
边栏推荐
- Four components and working principle of frequency converter
- 【Golang】golang中map元素的删除和清空
- 【Golang】golang实现发送微信服务号模板消息
- Web salted fish self rescue strategy -- typescript classes are not as difficult as you think
- Only "a little bit", why do developers look up to you?
- Simply understand MODBUS function code and partition
- UNIX C language POSIX thread creation, obtaining thread ID, merging thread, separating thread, terminating thread, thread comparison
- Development and course of Bluetooth Technology
- Redismission inventory deduction demo
- This should be postman, the most complete interface testing tool in the whole network
猜你喜欢

这才是开发者神器正确的打开方式!
![[attack and defense world web] difficulty five-star 15 point advanced question: ics-07](/img/97/555a76be9e96629fd7379ce8612a3b.png)
[attack and defense world web] difficulty five-star 15 point advanced question: ics-07

rs485通信OSI模型网络层

Redis 100 million level data storage scheme hash slot partition

selenium3自动化测试(这一篇就够了)——自学篇

"Low power Bluetooth module" master-slave integrated Bluetooth sniffer - help smart door lock

Use Modelsim to independently simulate Altera and Xilinx IP cores

Publish local image to private library

Self taught software testing talent -- not covered

Idea hidden Idea folder hides.Iml files
随机推荐
Redismission watchdog implementation mechanism can be understood at a glance
MicroBlaze adds a custom IP core and attaches the Axi bus to realize ssd1306 OELD drive
Research on parameter setting of MATLAB FFT
Four components and working principle of frequency converter
Openresty Lua resty logger socket log transfer
Exceptions about configuring Postgres parameters
Redismission inventory deduction demo
MySQL查询字段匹配某个规则的记录
Only "a little bit", why do developers look up to you?
【10】 Teamwork and cross team collaboration
Neo4j installation tutorial
Redis cluster setup
西门子200smart自创库与说明
Cub school learning - Kernel Development
Altium one key automatic BOM
Web salted fish self rescue strategy -- typescript classes are not as difficult as you think
Reptiles and counter crawls: an endless battle
Publish local images to Alibaba cloud
系统管理员需知的 16 个 iptables 使用技巧
【Golang】golang实现简单memcache