It looks like the WordPress editor caused me to get a "Memory usage way over your limit - processes killed" notification from Webfaction. There was nothing special going on — no one using the website (it was in maintenance mode) — just a few users logged into the WordPress editor. I couldn't figure out why that would max out my RAM and spawn several child processes:
User - Memory - Elapsed Time - Pid - Command:
username - 9MB - 0:10:38 - 502942 - php55.cgi
username - 14MB - 0:10:00 - 508769 - php55.cgi
username - 52MB - 0:09:57 - 508881 - php55.cgi
username - 54MB - 0:09:38 - 506676 - php55.cgi
username - 52MB - 0:09:07 - 503383 - php55.cgi
username - 53MB - 0:08:37 - 500031 - php55.cgi
username - 52MB - 0:08:08 - 506780 - php55.cgi
username - 52MB - 0:07:59 - 508766 - php55.cgi
username - 52MB - 0:07:37 - 509980 - php55.cgi
username - 53MB - 0:07:07 - 509888 - php55.cgi
username - 52MB - 0:06:38 - 506683 - php55.cgi
username - 52MB - 0:06:07 - 515563 - php55.cgi
username - 53MB - 0:06:00 - 517347 - php55.cgi
username - 52MB - 0:05:37 - 513738 - php55.cgi
username - 52MB - 0:05:07 - 517372 - php55.cgi
Working with WF support and also doing some research on my own, I came up with the fixes explained in my answer below, for anyone who's interested. Hope you find this helpful.
EDIT: I originally followed first Webfaction's suggestion of using FastCGI, but it was using up massive amounts of CPU for small tasks and limited some of the PHP functions available. A later WF suggestion, the memcached + object cache solution seems to work better. I am also using Lite Cache for serving cached pages to users. Much easier to use than some of the better-known caching plugins and very effective.
1) Install the AJAX Heartbeat Plugin:
It seems that the WordPress Heartbeat API (present since version 3.6) can put a heavy load on shared hosting servers when more than one person has the WP editor open, since it sends a ping from every connected browser every 15 seconds by default and also loads admin-ajax.php on just about every screen — and that's resource-intensive, especially on a site like ours where we may have six or ten people logged into the WordPress editor at once.
Someone created a WordPress plugin specifically to reduce the server load from this heartbeat function:
"Provides a method of turning the WordPress heartbeat off as well as change some settings. We use this plugin at RD because the heartbeat was clobbering site performance when more than one editor was logged into the CMS. In the future I plan to add the ability to adjust the settings.
Disables admin-ajax.php except on the posts & post edit pages
Disables hearbeat autostart
Sets the heartbeat interval to 60 seconds"
So I installed the plugin, and so far I haven't noticed any negative impact on site functionality.
2) Log out idle WordPress users
I reduced idle logout time from the WordPress default of 14 days to just 25 minutes (again, to reduce server load) using a GitHub fork of the Idle Logout plugin. (The original version on WordPress.org hasn't been updated since April 2013 and didn't work for me.)
3) Unless your site is new, install and run the WP-Optimize plugin. Our site had more than 5,000(!) post revisions, and after I ran WP-Optimize, the WP Dashboard ran a LOT faster! You can set this to run weekly (with the option of not deleting info from the last 2 weeks).
4) memcached + WordPress object cache
See How To Speed Up the WordPress Admin Panel
This really sped up performance of the WordPress Dashboard and dramatically reduced memory usage.
- Activate memcached (instructions). I'm using 64mb of memory.
- Install and build the PECL memcached extension as follows:
mkdir ~/pecl_install
cd ~/pecl_install/
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar zxf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure --prefix=$HOME
make
make install
export CPPFLAGS="-I$HOME/include $CPPFLAGS"
export LDFLAGS="-L$HOME/lib $LDFLAGS"
wget http://pecl.php.net/get/memcached-2.2.0.tgz
tar zxf memcached-2.2.0.tgz
cd memcached-2.2.0
phpize55
./configure --with-php-config=/usr/local/bin/php55-config --disable-memcached-sasl
make
mkdir ~/php55-exts
cp modules/memcached.so ~/php55-exts/
ln -s /usr/local/lib/php55/extensions/no-debug-non-zts-20121212/* ~/php55-exts/
- Download the Memcached Redux plugin (there are others to choose from as well). Don't install it — download it to your computer.
- Edit the object-cache.php as follows: Find
127.0.0.1
and replace it with /home/*yourusername*/memcached.sock
and then find 11211
and replace it with 0
… Then save the file and upload it to /wp-content
- You can confirm that memcached is running properly and view statistics by uploading and running the script phpMemcachedAdmin.
asked
03 Jul '14, 20:59
PeterA
104●3●12●24
accept rate:
14%