doumen5087 2014-02-06 13:13
浏览 40

优化Nginx和PHP5-FPM中的CPU使用率

I have a site serving Wordpress + Nginx + PHP5-FPM + **WP Super Cache. The server is a Digital Ocean droplet, with 4gb of memory and 2 cores. At times (like yesterday), CPU usage is around 90% and the site will become very slow. Most of the time it is between 30-50%.

Other articles I've read about "high" Nginx and PHP5-FPM usage mention rates of 40%+ for a single process. I'm not experiencing anything that unusual, but I wonder if my statistics are reasonable, given the machine and my Nginx configuration.

I've pasted nginx.conf here: http://pastebin.com/fD9HjqpB General wordpress configuration file (for Nginx): http://pastebin.com/CVkHZtvU And the site-specific config here: http://pastebin.com/KsVECwEa


Cpu(s): 47.8%us, 37.3%sy,  0.0%ni, 14.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   4049968k total,  1363176k used,  2686792k free,    35376k buffers
Swap:        0k total,        0k used,        0k free,   549984k cached

PID  USER      PR  NI  VIRT  RES  SHR  S   %CPU  %MEM  TIME+     COMMAND
667  mysql     20  0  1314m  85m  7908 S   89    2.2   17:10.21  mysqld
1679 www-data  20  0  229m   54m  3836 S   15    1.4   0:04.23   php5-fpm
1688 www-data  20  0  234m   59m  3696 R   12    1.5   0:01.21   php5-fpm
1682 www-data  20  0  237m   61m  3780 S   10    1.6   0:02.93   php5-fpm
1681 www-data  20  0  231m   56m  3848 S    9    1.4   0:03.26   php5-fpm
1684 www-data  20  0  237m   62m  3816 S    9    1.6   0:02.15   php5-fpm
1680 www-data  20  0  240m   65m  5204 S    7    1.7   0:03.47   php5-fpm
1686 www-data  20  0  237m   62m  3836 S    6    1.6   0:01.33   php5-fpm
1687 www-data  20  0  237m   62m  3820 S    6    1.6   0:00.97   php5-fpm
1691 www-data  20  0  229m   54m  3828 S    6    1.4   0:00.52   php5-fpm
721  www-data  20  0  130m   57m  1104 S    0    1.5   0:00.48   nginx

Is there anything I could be optimizing further to lower CPU usage and avoid the 90%+ usage periods? Obviously we could increase the size of the droplet, but I'm hoping to avoid scaling with hardware vs. just optimizing if there is opportunity.

Any insight would be greatly appreciated!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测