![]() |
Wordpress admin on nginx+php5-fpm on VPS incredibly slow. Other apps/WP front end OK
I've got extremely slow Wordpress under ISPConfig 3.0.4.1, but it's the back end only. I updated to WP 3.3 this morning, but still the same.
The strange thing is, I'm running a personal WP install on a free "tiny" instance on Amazon S3 with a similar config and low memory, but not ispc and it's Amazon's own RHEL, and it flies along. Which is what makes it even more difficult to diagnose. Anyway, here's a whole load of details: Wordpress 3.3 on Ubuntu 11.10 + Nginx 1.0.10 + php5-fpm 5.3.8 + ISPconfig 3.0.4.1 + 256Mb VPS I've got a 256Mb VPS running a Zen Cart store and phpbb3, both in different php-fpm pools. There's hardly anything running except the essentials and both those sites absolutely rocket along. As does the front end of the Wordpress site, when W3TC accelerated. BUT.... the admin side takes 6-10 seconds to do anything. There's nothing in the mysql slow log, or the php-fpm error log, the load doesn't spike, and the memory usage doesn't shoot up (but see below about memory). The first time it loads, at wp-admin/options.php it shows a very long page that looks wrong, with line after line of stuff like... active_plugins SERIALIZED DATA Here's the main items from ps_mem.py Code:
732.0 KiB + 87.5 KiB = 819.5 KiB bashload average: 0.48, 0.53, 0.51 And here's the output from free -m Code:
total used free shared buffers cachedCode:
server {Here's the php5-fpm pool conf for that site: Code:
[web9]I had to make changes to /etc/php5/conf.d/suhosin.ini as advised by phpmyadmin, and also upped the memory limit for WP as I was getting "ALERT - script tried to increase memory_limit to 268435456 bytes which is above the allowed value". Code:
; configuration for php suhosin moduleCode:
define('WP_MEMORY_LIMIT', '32M');I changed the theme to default, turned off all the plugins, changed all the mysql tables to to innodb and followed the recommendations of mysqltuner (even though, as I said, there's nothing about slow mysql in the logs I can see). I've tried changing php-fpm from socket to port and back, and so on and so forth. Not really sure what else to do now - can anyone spot anything here or advise? And yes, I might be running a bit tight on memory, but then why does Zen Cart and phpbb running with a big DB load pages sub 200ms? |
I guess thats you have a problem with I/O Bandwidth or in other words, the harddisk speed is too slow. I've seen this problem several times with vps servers when too many vps are on the same host system. This can also affect mysql performance. I guess there is not much that you can do about this except of talking with your hosting provider.
What you can try to optimize mysql; http://www.faqforge.com/linux/optimi...th-mysqltuner/ If your sites dont use innodb, then you should consider to switch innodb off in my.cnf file, so that mysql uses less memory. Quote:
|
Quote:
Quote:
Quote:
Code:
Database Data Size: 25,936 kB Database Index Size: 6,496 kB |
Quote:
Quote:
One indicator for low harddisk performance is e.g. when you run: rkhunter -c and the results are slow, rkhunter searches trough a lot of files, so if its slow, then your harddisk performance is low. One other thing that you might want to check is if the nameservers in /etc/resolv.conf are rechable and responding fast. |
I found the answer! Scroll down, but first, some answers...
Quote:
Quote:
Well, I think we can deal with the DB side of things quite quickly - here's the output from wordpress in debug mode: [0] => SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.ID = 4 AND wp_posts.post_type = 'page' ORDER BY wp_posts.post_date DESC [1] => 0.032161951065063 [2] => require, wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, W3_Db->query [0] => SELECT p.* FROM wp_posts AS p WHERE p.post_date < '2011-09-14 09:45:51' AND p.post_type = 'page' AND p.post_status = 'publish' ORDER BY p.post_date DESC LIMIT 1 [1] => 0.0060410499572754 [2] => require, require_once, include, get_header, locate_template, load_template, require_once, wp_head, do_action, call_user_func_array, adjacent_posts_rel_link_wp_head, adjacent_posts_rel_link, get_adjacent_post_rel_link, get_adjacent_post, W3_Db->query [0] => SELECT p.* FROM wp_posts AS p WHERE p.post_date > '2011-09-14 09:45:51' AND p.post_type = 'page' AND p.post_status = 'publish' ORDER BY p.post_date ASC LIMIT 1 [1] => 0.00027585029602051 [2] => require, require_once, include, get_header, locate_template, load_template, require_once, wp_head, do_action, call_user_func_array, adjacent_posts_rel_link_wp_head, adjacent_posts_rel_link, get_adjacent_post_rel_link, get_adjacent_post, W3_Db->query [0] => SELECT comment_approved, COUNT( * ) AS num_comments FROM wp_comments GROUP BY comment_approved [1] => 0.00011110305786133 [2] => require, require_once, include, get_footer, locate_template, load_template, require_once, wp_footer, do_action, call_user_func_array, wp_admin_bar_render, do_action_ref_array, call_user_func_array, wp_admin_bar_comments_menu, wp_count_comments, W3_Db->query So that doesn't even total 0.1 seconds for the db query part of things. Quote:
So, in fact, it was none of those things.... Two days of my life and a helluva lot of learning about things like xdebug, I can safely say you CANNOT now run WordPress on a VPS with less than 512Mb RAM. Which is a shame, because the 256Mb VPS had always been perfectly good before. Previously, it had been OK. You remember in my original post, I noted the line about "ALERT - script tried to increase memory_limit to 268435456 bytes which is above the allowed value"? Well, I also noted that I didn't see any memory spiking in the command line utility "top". But clearly, that doesn't refresh fast enough. With a bit of help from the VPS host who has graphical tools, we were seeing bursts of 228Mb usage when the ADMIN side of WP 3.3 was trying to load. But the front end? Well, as I said before, that zipped along and barely even registered on their graph. I also mentioned that I tried limiting memory use in both php.ini and the wordpress config. Well, I stepped down through 256 to 128 to 64 to 32, although from 128Mb, it would only serve blank pages. EDIT: Turns out this is confirmed by another blogger: http://www.dev4press.com/2011/blog/b...vs-3-2-vs-3-3/ Quote:
Final note to pre-empt the inevitable "but you can get 1Gb RAM VPS very cheap these days" comment, yes, you can. And I've been badly burnt that way. Amazon EC2 looks incredibly tempting - but you try not being able to stop, recover, relaunch or save a backup or even a snapshot from a failed instance for the 6 days it takes support to reply. And as for HostEurope/Webfusion, hell will freeze over and I'll start listening to Justin Bieber before I even wish them on my worst enemy. So I'm happy that I can just pick up the phone and immediately speak to someone, in London, in English. |
Finally cracked it!
Finally, I've solved it!
The quick version: Running php-fpm on ubuntu: Code:
sudo nano /etc/php5/conf.d/apc.iniCode:
extension=apc.soCode:
apc.shm_size="196"If you've got limited memory, you could try: Code:
apc.shm_size="96"Code:
service php5-fpm restart.The long version I was so damn sick of this slow admin I just decided to keep going, trying stuff. Finally, I came across this post: http://stackoverflow.com/questions/3...e-memory-for-p then this http://groups.drupal.org/node/75583 which led me to this post: http://www.litespeedtech.com/support...ead.php?t=4366 and finally this: http://2bits.com/articles/high-php-e...rformance.html The key to this was "download http://pecl.php.net/get/APC extract and run the apc.php, there you have a nice diagram how your cache usage look like" It showed APC was completely using its tiny default 32Mb, and was 100% fragmented. I've been running it for an hour, and see Hits: 70874 (98.6%) Misses: 991 (1.4%) Used: 124.4 MBytes (63.5%) Fragmentation: 0.00% Before this tweak it was something like 70% misses and 100% fragmentation. No wonder Wordpress was running slow! |
I've switched to Xcache which seems to be faster for me (haven't done any benchmarking, but that's how it feels).
|
| All times are GMT +2. The time now is 09:55. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.