Editing a Post, 99% CPU?

I have a blog with ~15k posts, and a DB size of 14.4M.

The website works blazingly fast from the front end, but post-edit and post-listing screens hang – either loading partially or not at all.

Read More

Even worse, the entire server gets bogged down after trying…

Examining the process manager showed that /public_html/wp-admin/edit.php or /public_html/wp-admin/post.php (post-listing and post-edit, respectively – yeah I know they seem backwards) was eating 99% CPU.

I experienced this problem on a 3rd tier Bluehost VPS, so I upgraded to a Heart Internet Hybrid 250 (12core, 28gb ram) to try and mitigate the problem – no dice :/

Any help getting this resolved is greatly appreciated – telling clients they have to edit pages through phpMyAdmin is not an option 🙂

Running MySQL processes:

Id      User    Host        db  Command     Time    State   Info

338     leech.. localhost   leech.. Sleep   1959            NULL
426     tmhp_.. localhost   tmhp_.. Sleep   581             NULL
433     root    localhost   NULL    Sleep   132             NULL
441     root    localhost   NULL    Query   0       NULL    SHOW PROCESSLIST

Process Example:

Pid     Owner   Priority    CPU %   Memory %    Command
29447   tmhp        0       99.8    0.6         /usr/bin/php /home/tmhp/public_html/wp-admin/edit.php

Edit: This might be pertinent: When on the add-new or post-edit pages the title loads and is editable, but the content editor loads halfway, additionally, the text appears but is white and only visible when highlighted…

Also, using the 2012 theme with no plugins…

Edit2: Given enough time (~3-5 minutes), the post-edit page will load fully and the process will terminate. This doesn’t seem to happen with the post-listing page, however.

Additionally, I’ve narrowed down the problem on the post-edit page to the page-attributes meta-box.

As a short term remedy I’ve created a plugin which does the following:

//Remove some features of pages so editing is faster
if (is_admin()) :
function my_remove_meta_boxes() {
    remove_meta_box('pageparentdiv', 'page', 'side');
}
add_action( 'admin_menu', 'my_remove_meta_boxes' );
endif;

function remove_page_attribute_support() {
    remove_post_type_support('page','page-attributes');
}

add_action( 'init', 'remove_page_attribute_support' );


// Remove the Posts and Pages menus from the admin screen
function custom_admincss() {
   echo '<style type="text/css">
           #menu-pages{display:none !important}
           #menu-posts{display:none !important}
         </style>';
}

add_action('admin_head', 'custom_admincss');

Related posts

2 comments

  1. You may be dealing with the dreaded mod_security when your posting or updating . see if it’s enabled on the server first, if your using antimalware software it may be trying to scan on save . ok that’s the easy try . the next is to turn off your plugins . wsiwig editors., seo plugins . caching plugins . they all can contribute to post updates becoming really slow.. this is a one-at-a-time kinda thing so it gets tedious.

  2. I pinned it down to the hierarchy arg for the pages post-type:

    hierarchical

    (boolean) (optional) Whether the post type is hierarchical (e.g. page).

    Allows Parent to be specified. The ‘supports’ parameter should contain ‘page-attributes’ to show the parent select box on the editor page.

    Default: false

    Note: this parameter was planned for Pages. Be careful, when choosing it for your custom post type – if you are planning to have many entries (say – over 100), you will run into memory issue. With this parameter set to true WordPress will fetch all entries of that particular post type, together with all meta data, on each administration page load for your post type.

    Now, any idea how one can go about removing hierarchical support for pages w/o overwriting the core?

Comments are closed.