php-fpm优化
本文所涉及的配置文件名为php-fpm.conf,里面比较重要的配置项有如下一些。
request_terminate_timeout = 30
#表示等待30秒后,结束那些没有自动结束的php脚本,以释放占用的资源。
pm表示使用那种方式,就是static(静态)或者dynamic(动态)。在更老一些的版本中,dynamic被称作apache-like。
pm.max_children – This is used to set the maximum processes allowed pm.start_servers – The number of child processes created on startup pm.min_spare_servers – Defines the minimum number of idle processes pm.max_spare_servers – Sets the maximum number of idle server processes pm.process_idle_timeout – The number of seconds an idle process will be alive pm.max_requests – This sets the execution time of each child process and is used to curb memory leaks.
如果dm设置为static,那么其实只有pm.max_children这个参数生效,系统会开启设置数量的php-fpm进程。
如果dm设置为dynamic,那么pm.max_children参数失效,后面3个参数生效。后面3个参数生效,同时请注意,pm.max_spare_servers的值不能超过pm.max_children定义的值,否则php-fpm进程报错。
系统会在php-fpm运行开始 的时候启动pm.start_servers个php-fpm进程,然后根据系统的需求动态在pm.min_spare_servers和pm.max_spare_servers之间调整php-fpm进程数。 (more…)
Read More