WebFaction
Community site: login faq
2
1

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.
This question is marked "community wiki".

asked 03 Jul '14, 20:59

PeterA
10431022
accept rate: 14%

edited 11 Jul '14, 18:47


Answer is in the question :)

permanent link

answered 11 Jul '14, 16:13

seanf
12.2k41836
accept rate: 37%

Thanks for the tips. I just got a "process killed" on a similar set-up that's still in pre-production staging.

Regarding (3) above, in addition to WP-Optimize, you can also limit the number of stored post-revisions in wp-config.php. Just add:

 define( 'WP_POST_REVISIONS', 3 );

Swap 3 for whatever max. revisions you want.

You can also define limits on WP's memory usage in wp-config. I don't think WP should be requesting hundreds of MBs to begin with, but this may be a good last resort stopgap in addition to other fixes.

edit: After successfully following your great memcached + Wordpress guide, everything went smoothly, but had a little trouble getting the phpMemcachedAdmin script configured (Google seems to be no longer supporting it). After a few tries, I managed to work out the proper syntax for the server on the config:

Server > IP/Hostname: unix:///home/username/memcached.sock Port: 0

permanent link

answered 11 Sep '16, 02:52

peteleidy
934
accept rate: 0%

edited 20 Sep '16, 01:59

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×244
×87
×34
×28
×20

question asked: 03 Jul '14, 20:59

question was seen: 16,533 times

last updated: 02 Dec '16, 03:19

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM