In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you the example analysis of php-fpm parameters, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Ps aux | grep php-fpm | more
View total number of php-fpm
Php-fpm.conf configuration
Pid string
Location of the PID file. The default is empty.
Error_log string
The location of the error log. Default: installation path # INSTALL_PREFIX#/log/php-fpm.log.
Log_level string
Error level. Available levels are: alert (must be dealt with immediately), error (error condition), warning (warning condition), notice (general important information), debug (debugging information). Default: notice.
Emergency_restart_threshold int
If the child process receives the SIGSEGV or SIGBUS exit information number for the number of times the parameter is set within the time set by emergency_restart_interval, FPM will restart. 0 means' turn off the feature'. Default value: 0 (off).
Emergency_restart_interval mixed
Emergency_restart_interval is used to set the interval between smooth restarts. This helps to solve the problem of using shared memory in accelerators. Available units: s (seconds), m (minutes), h (hours), or d (days). Default unit: s (seconds). Default value: 0 (off).
Process_control_timeout mixed
Sets the timeout for the child process to accept the main process multiplexing signal. Available units: s (seconds), m (minutes), h (hours), or d (days) default units: s (seconds). Default value: 0.
Daemonize boolean
Set FPM to run in the background. Set 'no' to keep FPM running in the foreground for debugging. Default value: yes.
Running configuration section
In FPM, you can use different settings to run multiple process pools. These settings can be set individually for each process pool.
Listen string
Set the address to accept FastCGI requests. The available formats are: 'ip:port',' port','/ path/to/unix/socket'. Each process pool needs to be set up.
Listen.backlog int
Sets the semi-connection queue length of listen (2). '- 1' means no limit. Default value:-1.
Listen.allowed_clients string
Sets the IPV4 address of the server that is allowed to connect to FastCGI. Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in PHP FastCGI (5.2.2 +). Works only for TCP snooping. Each address is separated by a comma. If it is not set or empty, any server is allowed to request a connection. Default value: any.
Listen.owner string
If used, it sets permissions for Unix sockets. In Linux, read and write permissions must be set for WEB server connections. In many BSD-derived systems, permissions can be ignored to allow free connections. Default value: the user used in the operation is shared, and the permission is 0666.
Listen.group string
See listen.owner.
Listen.mode string
See listen.owner.
User string
The Unix user that the FPM process is running. Must be set.
Group string
The Unix user group that the FPM process is running. If it is not set, the default user's group is used.
Pm string
Sets how the process manager manages child processes. Available values: static, dynamic. Must be set.
Static-the number of child processes is fixed (pm.max_children).
Dynamic-the number of child processes is dynamically set based on the following configuration: pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers.
Pm.max_children int
The number of child processes. The number of child processes created when pm is set to static and the maximum number of child processes that can be created when pm is set to dynamic. Must be set.
This option sets the limit on the number of requests that can be provided at the same time. The setting of MaxClients in mpm_prefork similar to Apache and the PHP_FCGI_CHILDREN environment variable in normal PHP FastCGI.
Pm.start_servers in
Sets the number of child processes created at startup. Used only when pm is set to dynamic. Default value: min_spare_servers + (max_spare_servers-min_spare_servers) / 2.
Pm.min_spare_servers int
Sets the minimum number of idle service processes. Used only when pm is set to dynamic. Must be set.
Pm.max_spare_servers int
Sets the maximum number of idle service processes. Used only when pm is set to dynamic. Must be set.
Pm.max_requests int
Sets the number of requests for services before each child process is reborn. It is very useful for third-party modules that may have memory leaks. If set to'0', requests are always accepted. It is equivalent to the PHP_FCGI_MAX_REQUESTS environment variable. Default value: 0.
Pm.status_path string
The URL of the FPM status page. If it is not set, the status page cannot be accessed. Default value: none.
Ping.path string
The ping URL of the FPM monitoring page. If it is not set, the ping page cannot be accessed. This page is used to externally detect whether the FPM is alive and can respond to requests. Please note that it must begin with a slash.
Ping.response string
Used to define the corresponding return of the ping request. Returns text in text/plain format as HTTP 200. Default value: pong.
Request_terminate_timeout mixed
Sets the timeout abort time for a single request. This option may be useful for scripts in the php.ini setting where 'max_execution_time' does not stop running for some special reason. Set to'0' means' Off'. Available units: s (econds) (default), m (inutes), h (ours), or d (ays). Default value: 0.
Request_slowlog_timeout mixed
When a timeout for this setting is requested, the corresponding PHP call stack information is fully written to the slow log. Set to'0' means' Off'. Available units: s (seconds) (default), m (minutes), h (hours), or d (days). Default value: 0.
Slowlog string
Log of slow requests. Default value: # INSTALL_PREFIX#/log/php-fpm.log.slow.
Request_slowlog_timeout
Range: php-fpm.conf option
Classification: convenience
This option allows you to track slow scripts and record them in the log file along with the call stack. For example, the settings are as follows:
5s
Logs/slow.log
The recorded slow.log might look like this:
The copy code is as follows:
Sep 21 16 virtual 22 pool default 19.399162 pid 29715
Script_filename = / local/www/stable/www/catalogue.php
[0x00007fff23618120] mysql_query () / srv/stable/common/Database/class.MySQLRequest.php:20
[0x00007fff23618560] getResult () / srv/stable/common/Database/class.Facade.php:106
[0x00007fff23618aa0] query () / srv/stable/common/mysite.com/ORM/class.UsersMapper.php:99
[0x00007fff23618d60] resolveByID () / srv/stable/common/mysite.com/ORM/class.User.php:629
[0x00007fff236193b0] getData () / srv/stable/common/class.DataEntity.php:90
[0x00007fff236195d0] load () / srv/stable/common/mysite.com/ORM/class.User.php:587
[0x00007fff23619a00] getIsHidden () / srv/stable/common/mysite.com/class.User.php:42
[0x00007fff2361a470] getName () / local/www/stable/www/catalogue.php:41
At the same time, the following records are saved in error.log:
Sep 21 16 fpm_request_check_timed_out 22 fpm_request_check_timed_out (), line: child 29715, script'/ local/www/stable/www/catalogue.php' (pool default) executing too slow (5.018002 sec), logging
As you can see in another example, the script ran for more than 5 seconds, most likely due to slow mysql response (top backtrace).
Rlimit_files int
Sets the rlimit limit for file opening descriptors. Default value: system-defined value.
Rlimit_core int
Set the core rlimit maximum limit. Available values: 'unlimited', 0, or positive integer. Default value: system-defined value.
Chroot string
The Chroot directory at startup. The defined directory needs to be an absolute path. If it is not set, chroot is not used.
Chdir string
Set up the startup directory, which will be automatically Chdir at startup. The defined directory needs to be an absolute path. Default value: current directory, or / directory (when chroot).
Catch_workers_output boolean
Redirect the stdout and stderr during the run to the main error log file. If not set, stdout and stderr will be redirected to / dev/null according to the rules of FastCGI. Default value: empty.
You can also pass additional environment variables to a runtime pool, or update PHP configuration values. You can do this under the following configuration parameters in php-fpm.conf:
Example # 1 passes environment variables and sets configuration values for PHP to the running pool
Env [HOSTNAME] = $HOSTNAME
Env [PATH] = / usr/local/bin:/usr/bin:/bin
Env [TMP] = / tmp
Env [TMPDIR] = / tmp
Env [TEMP] = / tmp
Php_admin_ value [Sendmail _ path] = / usr/sbin/sendmail-t-I-f www@my.domain.com
Php_ display [display _ errors] = off
Php_admin_ value [error _ log] = / var/log/fpm-php.www.log
Php_admin_ errors [log _ log] = on
Php_admin_ value [memory _ limit] = 32m
The PHP configuration value is set by php_value or php_flag and overrides the previous value. Note that the values defined by disable_functions or disable_classes in php.ini will not be overwritten, but the new settings will be appended to the original values.
Values defined with php_admin_value or php_admin_flag cannot be overridden by ini_set () in PHP code.
FAQ
Can Q:php-fpm be used with ZendOptimize?
A: absolutely.
Can Q:php-fpm be used with optimizers such as ZendPlatform, xcache, eAccelerator, APC, etc.
A: yes. The architecture of php-fpm and any kind of shared memory for opcode caching are applicable. The only limitation is that all worker processes can only apply to one cache, even if they run with a different uid/gid
Q: why should I patch php? Spawn-fcgi doesn't need this!
A:php-fpm was created to enhance ease of management. Unpatched php cannot do this:
Restart php smoothly without losing requests, including upgrading php binaries and / or extensions.
Run the worker process with different uid / gid / chroot environments
All settings have only one configuration file
Dynamic request based on load (TODO)
Real-time statistical performance for php requests (TODO)
Q: why run php-fpm with root? Is it safe?
A: launching php-fpm with root makes sense only if you plan to use php from different uid/gid to process requests. For example, different sites on a shared host. Because it is only when the master process is running with root that child processes of different uid/gid can be created. It's quite safe. The master process never processes the request itself.
Under no circumstances will php- fpm use the root identity to process the request.
Can Q:php-fpm speed up php script processing?
A: no, it won't affect the processing speed. However, if you use some special features, there can be a performance improvement for specific requests.
Q: if I migrate my website from mod_php to php-fpm, will I get a performance improvement?
A: in general, the performance improvement you can get from migrating to php-fpm may not be significant when there is a large amount of free memory available on the server. However, if there is not enough memory, the performance improvement is considerable, which can reach 300-500% in some cases. This may be because nginx + php-fpm generally uses less memory than Apache + mod_php. And VFS caching works more efficiently because of more free memory.
Will Q php-fpm be included in the official php in the future?
A: I hope so. Currently, the protocol for php-fpm code is GPL. So now the php-fpm code doesn't match the php protocol (similar to bsd). This is a temporary measure. This choice is made to simplify the development process. Once the code is fully functional, such as adaptive generation subprocesses and other things, the protocol will be changed to a match. After that, php-fpm will be officially released to the php development team and recommended to be included.
The above is all the contents of the article "sample Analysis of php-fpm parameters". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.