VPS侦探论坛

 找回密码
 注册
查看: 6658|回复: 8

cpu一直高负荷

[复制链接]
发表于 2013-11-23 22:27:48 | 显示全部楼层 |阅读模式

在论坛搜索了所有的cpu100%的例子 php-fpm跑满屏 也都按照修改php-fpm  my.cnf 但是都没有效果 希望军哥帮忙看看 谢谢

还请军哥帮忙看看 感激不尽

[ 本帖最后由 superman 于 2013-11-24 10:33 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2013-11-24 09:38:45 | 显示全部楼层


这个只能看到在那个时间挂了,无法分析可能的原因
建议php-fpm.conf里加上request_terminate_timeout = 5s 后面的这个秒数可以自己定义,看看慢日志里有什么有用的信息
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2013-11-24 12:42:02 | 显示全部楼层

回复 2# 的帖子


[24-Aug-2013 20:48:14] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 34 total children
[24-Aug-2013 20:48:37] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 23 total children
[24-Aug-2013 20:48:38] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 24 total children
[24-Aug-2013 20:48:39] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 25 total children
[24-Aug-2013 20:48:40] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 26 total children
[24-Aug-2013 20:48:41] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 27 total children
[24-Aug-2013 20:48:42] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 32 children, there are 0 idle, and 28 total children



全都是这些提示 是否是起始服务器太少?这个值弄到多少算ok?怎么去计算这个值呢?

我现在的php-fpm 配置如下  
[www]
listen = /tmp/php-cgi.sock
user = www
group = www
pm = dynamic
pm.max_children =200
pm.start_servers = 8
pm.min_spare_servers = 4
pm.max_spare_servers = 100
request_terminate_timeout = 5s
我的cpu是1G单核的,希望军哥给点建议,如何设置比较合理,现在的设置cpu经常跑到100%  
而且同时优化数据库所有表常会出现502错误  优化数据库单个表不会出现  是否需要增加服务器内存? 谢谢

[ 本帖最后由 superman 于 2013-11-24 12:53 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2013-11-24 14:25:08 | 显示全部楼层



Mem  是你的内存。假设为1G
pm.max_children = Mem/2/20     =》1024/2/20= 25

pm.start_servers = Mem/2/30     =》 1024/2/30=17

pm.min_spare_servers = Mem/2/40   =》 1024/2/40= 12

pm.max_spare_servers = Mem/2/20  =》 1024/2/20=25
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2013-11-24 14:31:56 | 显示全部楼层

pm.min_spare_servers调到20看看,这个具体也不好说,根据使用情况适当调调
pm.start_servers的话官网建议是min_spare_servers + (max_spare_servers - min_spare_servers) / 2。


502一般都是php-fpm的问题,前面已经说了,开慢日志看看,一般那里执行的慢都会有记录

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2013-11-24 15:03:52 | 显示全部楼层

回复 4# 的帖子


谢谢,受教了 我测试看看
 楼主| 发表于 2013-11-24 15:04:08 | 显示全部楼层

回复 5# 的帖子


感谢军哥  我测试下
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2013-11-24 23:52:32 | 显示全部楼层

回复 5# 的帖子


军哥,今天测试了一下午 发现改成50还是不行的  

pm.start_servers = 50
pm.min_spare_servers = 50
pm.max_spare_servers = 100

操作多个表的话 还是会报503 现在就是在后台更新下缓存都会报502 Bad Gateway
是不是我数据库数据太多了?还是我内存不够用需要加内存 ?
开启慢日志 里面报的错误都是入口文件执行时间过长 比如forum.php  home.php这些
希望军哥指点下

[ 本帖最后由 superman 于 2013-11-25 09:52 编辑 ]
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2013-11-25 10:07:45 | 显示全部楼层

看看内存占用swap如果基本没用或用的很少一般不需要升级

可以尝试按置顶帖的要求改改执行时间之类的参数试试,或排查一下插件

军哥运维代购:http://shop63846532.taobao.com/

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-25 05:26 , Processed in 0.027692 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表