当前位置:网站首页>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
边栏推荐
- Lanqiao cup provincial training camp - stack and recursion
- MySQL engine
- 系统管理员需知的 16 个 iptables 使用技巧
- MySQL查询字段匹配某个规则的记录
- [interview: Basics 01: integer binary search]
- HDU5667 Sequence
- Exceptions about configuring Postgres parameters
- Build resume editor based on Nocode
- UNIX C language POSIX thread creation, obtaining thread ID, merging thread, separating thread, terminating thread, thread comparison
- selenium3自动化测试(这一篇就够了)——自学篇
猜你喜欢

Xilinx FPGA Microblaze AXI_ IIC usage and experience

Lanqiao cup provincial training camp - stack and recursion

【10】 Teamwork and cross team collaboration

【直播报名】Location Cache 模块浅析及 OCP 监控、报警详解

Only "a little bit", why do developers look up to you?

08【AIO编程】

Simply understand MODBUS function code and partition

Pytorch learning -- using gradient descent method to realize univariate linear regression

关于【软件测试-自动化测试之面试技巧和注意事项】——侃侃而谈

Idea background image set
随机推荐
简单使用 MySQL 索引
RS485 communication OSI model network layer
Installing Oracle Xe with Linux
Working principle and function application of frequency converter
[live registration] analysis of location cache module and detailed explanation of OCP monitoring and alarm
This is the right way for developers to open artifact!
简单理解modbus功能码和分区
[golang] deletion and emptying of map elements in golang
Decomposition of kubernets principle
[white hat talks about web security] Chapter 1 my security world view
基于NoCode构建简历编辑器
MySQL engine
Capture and handling of JDBC exception sqlexception
LDR6028充电OTG直播线直播声卡音频转接器最具性价比方案
2022,软测人的平均薪资,看完我瞬间凉了...
The bean injected through @autowired can still be injected even if the class is not annotated with annotations such as @comment
浅析拉格朗日乘数法及其对偶问题
Reptiles and counter crawls: an endless battle
High speed ADC test experience
[golang] golang implements MD5 encryption function