关于php配置参数

没事查看了一下php日志,发现提示进程数不够,日志信息如下:

[04-Nov-2014 14:19:08] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_serve

rs), spawning 8 children, there are 0 idle, and 15 total children

[04-Nov-2014 14:29:27] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_serve

rs), spawning 8 children, there are 0 idle, and 16 total children

[04-Nov-2014 16:51:04] NOTICE: Finishing ...

[04-Nov-2014 16:51:04] NOTICE: exiting, bye-bye!

[04-Nov-2014 16:51:06] NOTICE: fpm is running, pid 31023

[04-Nov-2014 16:51:06] NOTICE: ready to handle connections

[04-Nov-2014 19:01:05] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_serve

rs), spawning 8 children, there are 0 idle, and 17 total children

[04-Nov-2014 19:54:47] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_serve

rs), spawning 8 children, there are 0 idle, and 17 total children

[04-Nov-2014 20:36:06] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_serve

rs), spawning 8 children, there are 0 idle, and 19 total children

[04-Nov-2014 21:18:56] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_serve

rs), spawning 8 children, there are 0 idle, and 17 total children

[05-Nov-2014 05:30:04] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_serve

rs), spawning 8 children, there are 0 idle, and 15 total children

[05-Nov-2014 11:01:37] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_serve

rs), spawning 8 children, there are 0 idle, and 17 total children

[05-Nov-2014 11:01:38] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_serve

rs), spawning 16 children, there are 0 idle, and 21 total children

使用下面的命令查看php进程:

[[email protected] ~]# ps -ef |grep php

root     25874 20907  0 11:56 pts/0    00:00:00 more index.php

www      26030 31023 32 12:02 ?        00:00:26 php-fpm: pool www

www      26037 31023 31 12:02 ?        00:00:22 php-fpm: pool www

www      26042 31023 31 12:02 ?        00:00:20 php-fpm: pool www

www      26046 31023 30 12:02 ?        00:00:17 php-fpm: pool www

www      26054 31023 30 12:02 ?        00:00:15 php-fpm: pool www

www      26059 31023 30 12:02 ?        00:00:14 php-fpm: pool www

www      26062 31023 30 12:03 ?        00:00:12 php-fpm: pool www

www      26063 31023 30 12:03 ?        00:00:09 php-fpm: pool www

www      26066 31023 30 12:03 ?        00:00:09 php-fpm: pool www

www      26089 31023 23 12:03 ?        00:00:02 php-fpm: pool www

www      26092 31023 24 12:03 ?        00:00:01 php-fpm: pool www

root     26097 25911  0 12:03 pts/1    00:00:00 grep php

root     31023     1  0 Nov04 ?        00:00:09 php-fpm: master process (/usr/local/php5/etc/php-fpm.conf)

内存占用情况:只用了2G左右的内存

[[email protected] etc]# free -m

total       used       free     shared    buffers     cached

Mem:         19990      19685        304          0        256      16949

-/+ buffers/cache:       2480      17509

Swap:        19999        112      19887

打开配置文件php-fpm.conf发现:pm.max_children = 5

修改成如下参数后,发现php日志中无此报警了:

; Note: This value is mandatory.

pm.max_children = 1024

; The number of child processes created on startup.

; Note: Used only when pm is set to ‘dynamic‘

; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2

pm.start_servers = 512

; The desired minimum number of idle server processes.

; Note: Used only when pm is set to ‘dynamic‘

; Note: Mandatory when pm is set to ‘dynamic‘

pm.min_spare_servers = 4

; The desired maximum number of idle server processes.

; Note: Used only when pm is set to ‘dynamic‘

; Note: Mandatory when pm is set to ‘dynamic‘

pm.max_spare_servers = 512

查看php-fpm的子进程数,跟配置文件里面设置的一样,等于pm.start_servers+pm.min_spare_servers

[[email protected] etc]# ps -ef |grep php |wc -l

515

修改php配置文件后,内存占用从2G变成了6.8G左右,增长了4.8G左右,一个php进程开销占到了8M左右,这个可以根据实际的内存情况来进行修改。

[[email protected] log]# free -m

total       used       free     shared    buffers     cached

Mem:         19990      19438        551          0        189      12414

-/+ buffers/cache:       6835      13154

Swap:        19999        129      19870

补充:

php-fpm有一个参数 max_requests,该参数指明了,每个children最多处理多少个请求后便会被关闭,默认的设置是500。因为php是把请求轮询给每个children,在大流量下,每个childre到达max_requests所用的时间都差不多,这样就造成所有的children基本上在同一时间被关闭,这样会导致此时nginx发给php的请求无法得到相应,会出现短时间的502.解决方法:

增加children的数量,并且将 max_requests 设置未 0 或者一个比较大的值

一般增加max_requests到102400,可能有效果。

时间: 2024-08-14 17:23:33

关于php配置参数的相关文章

关于ntp时间同步理论及配置参数-20170804

[原创]关于ntp时间同步理论及配置参数20170804 前言 NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议.无论是平时使用的私人计算机还是在工作中搭建的服务器集群,时间的统一性和准确性是十分重要的.它是用来同步网络中各个计算机的时间的协议. 在计算机的世界里,时间非常地重要,例如对于火箭发射这种科研活动,对时间的统一性和准确性要求就非常地高,是按照A这台计算机的时间,还是按照B这台计算机的时间?NTP就是用来解决这个问题的,NT

linux学习笔记——搭建基于nginx的web服务器、多核配置、nginx配置参数

############ 认识nginx #############Nginx:(发音同 engine x)是一款轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.由俄罗斯的程序设计师Igor Sysoev所开发,最初供俄国大型的入口网站及搜寻引擎Rambler(俄文:Рамблер)使用.  其优点是轻量级(占有内存少),高并发(并发能力强),事实上nginx的并发能力确实在同类型的网页伺服器中表现较好.目前中国大陆使用ngi

网站前端_KindEditor.基础入门.0001.KindEditor_3.4.2配置参数?

初始方式: 说明: 在快速入门中使用KE.show({ .. .})来初始化了一个编辑器,具体进入js/kindeditor.js下可以看到KE对象下的show方法先调用了KE的init方法然后又调用了其event事件对象的ready方法,内部其实是调用的KE的create方法,传递的参数为args的id属性,所以可通过2种方式来初始化编辑器 # 方式一 : # 方式二 : 注意: 无论使用哪种方式初始化编辑器,都需要传递配置对象{ ... },配置对象中id属性是必须配置的,其它的属性默认采用

项目中Zookeeper配置参数笔记

ZooKeeper是以Fast Paxos算法为基础的,Paxos 算法存在活锁的问题,即当有多个proposer交错提交时,有可能互相排斥导致没有一个proposer能提交成功,而Fast Paxos作了一些优化,通过选举产生一个leader (领导者),只有leader才能提交proposer,具体算法可见Fast Paxos.因此,要想弄懂ZooKeeper首先得对Fast Paxos有所了解. ZooKeeper的基本运转流程: 1.选举Leader. 2.同步数据. 3.选举Leade

笔记01 登录、常用配置参数、Action访问Servlet API 和设置Action中对象的值、命名空间和乱码处理、Action中包含多个方法如何调用

Struts2登录 1. 需要注意:Struts2需要运行在JRE1.5及以上版本 2. 在web.xml配置文件中,配置StrutsPrepareAndExecuteFilter或FilterDispatcher 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <filter>     <filter-name>struts2</filter-name>     <filter-class>org.apache.struts2.di

【原创】MySQL性能优化-I/O相关配置参数

本文介绍InnoDB和MyISAM两种存储引擎的I/O相关参数配置. 1.InnoDB  I/O相关配置 Innodb是一种事务型的存储引擎,为了减少提交事务时产生的io开销,innodb采用了写日志的方式,也就是在事务提交的时候会先写入事务日志中 ,而不是每次都把修改或者数据刷新到数据文件中,这样做是为了提高io的性能,因为事务的修改,使数据和索引文件通常都会映射到表空间随机的位置,所以刷新数据变更到数据文件会产生大量随机io,而记录日志是顺序io,一旦事务日志安全的写到磁盘中,数据就算是持久

Java虚拟机配置参数(目前不够完善)

最近看了有关虚拟机的书籍,发现有很多虚拟机配置参数不知道,特来记录一下, -XX: MaxDirectMemorySize--->设置直接内存,不设置与Java堆内存最大值一致 -XX:PermSize和-XX:MaxPermSize--->设置方法区大小 -Xoss--->设置本地方法栈大小 -XX:+HeapDumpOnOutOfMemoryError--->生成内存溢出快照(查看内存溢出快照的工具,安装JDK时,有自带了几种工具,具体怎么使用百度.谷歌) -XX:+/-Use

nginx配置参数详解

配置参数详解 user nginx nginx ; Nginx用户及组:用户 组.window下不指定 worker_processes 8; 工作进程:数目.根据硬件调整,通常等于CPU数量或者2倍于CPU. error_log  logs/error.log;  error_log  logs/error.log  notice;  error_log  logs/error.log  info;  错误日志:存放路径. pid logs/nginx.pid; pid(进程标识符):存放路径

jsp 使用application.getInitParameter来获取web.xml中配置参数

jsp中9个内置对象之一application,它的数据对整个web应用都有效,application有一个重要的用途就是获取web.xm中的配置参数,这样可以提高代码的移植性.应用案例如下: 在web.xml中配置如下代码: <context-param> <param-name>driver</param-name> <param-value>com.mysql.jdbc.Driver</param-value> </context-p

Apache优化配置——配置参数

●Apache配置参数 ⑴KeepAlive On/Off: KeepAlive指的是保持连接活跃,也就是说,如果将KeepAlive设置为On,那么来自同一客户端的请求就不需要再一次连接,避免每次请求都要创建一个连接而加重服务器的负担.一般情况下,图片较多的网站应该把KeepAlive设为On. ⑵KeepAliveTimeOut number: 如果第二次请求和第一次请求之间超过KeepAliveTimeOut的时间,第一次连接就会中断,再新建第二个连接.它的设置一般考虑图片或者JS等问价再