在Ubuntu VPS上提高WordPress后端的速度

我有一个运行在我的VPS上的WordPress站点,这个站点是相当高规格的(3520MB RAM,4个内核)。 服务器运行Nginx和php5-fpm。

虽然该网站在前端有响应,但后端往往会很慢,一些pipe理页面需要几秒钟才能加载。 该网站运行WooCommerce,但我有WP总caching运行以及APC对象caching。

我的问题是真的关于php5-php的configuration,因为我想我可能没有设置最佳利用服务器的资源。 这是我在php5池中的www.conf

 pm.max_children = 10 ; 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 = 2 ; 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 = 1 ; 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 = 3 ; The number of seconds after which an idle process will be killed. ; Note: Used only when pm is set to 'ondemand' ; Default Value: 10s ;pm.process_idle_timeout = 10s; ; The number of requests each child process should execute before respawning. ; This can be useful to work around memory leaks in 3rd party libraries. For ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. ; Default Value: 0 ;pm.max_requests = 500 

我也有define('WP_MEMORY_LIMIT', '196M'); 在wp-config中。

我可以采取什么明显的步骤来提高pipe理区域的速度?

编辑

检查日志,我看到了很多这样的:

[01-Oct-2014 20:56:38]警告:[池www]似乎很忙(你可能需要增加pm.start_servers,或pm.min / max_spare_servers),产卵16个孩子,有0空闲,7总孩子

我能做什么来解决?

编辑2

加载pipe理页面时使用top命令。 这些价值是否合理?

  PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 23237 www-data 20 0 381m 45m 31m S 10.3 1.4 0:03.52 php5-fpm 23229 www-data 20 0 385m 76m 60m S 5.0 2.3 0:09.54 php5-fpm 23230 www-data 20 0 613m 58m 39m S 4.7 1.7 0:06.38 php5-fpm 1425 www-data 20 0 121m 7000 2292 S 1.3 0.2 87:43.85 nginx 

好吧,我发布了这个年龄前,有点放弃。 然后,我决定重温并做一些研究。

我的服务器使用APC操作码caching来提高php的性能。 我把一个apc.php文件放在我的网站的根目录下,这让我可以看到caching的统计信息。 碎片率达到了100%,而ti则超过了50%。

/etc/php5/conf.d/apc.ini文件中,我只需要更新configuration设置,具有以下内容:

 apc.shm_size = 256 apc.max_file_size = 12M apc.ttl=0 

重启php

 sudo service php5-fpm restart 

我的服务器有一个相当数量的内存(大约3.5GB),所以这不会消耗太多,已经导致碎片接近零,并错过了大约3-4%。 速度的提高是巨大的,页面现在可以在1-2秒内加载,而不像以前那样加载6-8次。


来源和进一步的细节: