+ Reply to Thread
Results 1 to 5 of 5

Thread: How do we know which Wordpress plugins causes High CPU Usage?

  1. #1
    vekou's Avatar
    vekou is offline x10 Sophmore vekou is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    162

    Question How do we know which Wordpress plugins causes High CPU Usage?

    Recently, I have been suspended 3x for High Resource Usage. I know what I'm supposed to do, disable the plugins and enable them one by one to see which plugin is the culprit. I've been experimenting this for months now, and still I get suspended. The problem is, even if I enable all of my plugins (I don't use too much plugins by the way), I don't get High Resource Usage and everything works normally. Then after about a few days to about a week, my website will be suspended. I installed a plugin that will monitor my Wordpress memory usage, and it is constant at about 7%. I wouldn't be suspended for using around 18MB of memory from the 64MB allocated.

    My questions are:
    • Aside from this troubleshooting method, what other methods can we use to know if we are reaching the resource usage limit?
    • I know that memory is not the only resource that is counted in the limit, i think it also includes the time a script is run, etc. What other resources are included in the limit and what those limits are?
    • I've noticed that everytime I get suspended, after unsuspending myself, I notice a few spams awaiting for moderation that weren't caught by Akismet. If Akismet is down and spam comments keep flooding in, will this hit the High Resource Limit since the script will probably keep on trying to contact the Akismet server?
    • Am I making sense?
    We hate people who solicit reputation using their signatures. Click if you agree.

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: How do we know which Wordpress plugins causes High CPU Usage?

    I can't answer your questions definitively, but I can tentatively.

    Quote Originally Posted by vekou View Post
    • Aside from this troubleshooting method, what other methods can we use to know if we are reaching the resource usage limit?
    Sadly, I know of no methods that are easy or have a high likelihood of succeeding.

    From PHP, you could get current processor stats (including CPU usage) using procfs, but PHP on the free hosts is restricted in what can be accessed via the filesystem. This would also require altering the plugins to add scaffolding at various points in them to log CPU usage. Adding scaffolding to log memory usage is still a possibility, but not an easy one.

    A PHP profiler (such as Xdebug) can be used to gather information on how long various functions execute in a script. With that information, you could see how much time is spent in the functions each plugin defines. Since none is installed on the X10 hosts (and never will be; profilers aren't for production servers), you'd need to set up your own server to use one.

    Since what you really need is a way of getting information at the moment WP reaches the resource usage limits, I doubt the above will be very helpful. The surest way is to start with no (or very few) plug-ins enabled, then enable one every other week. You could enable (then disable) more than one at each step, going for a binary search approach, but that will cause quite a few suspensions.

    Quote Originally Posted by vekou View Post
    • I know that memory is not the only resource that is counted in the limit, i think it also includes the time a script is run, etc. What other resources are included in the limit and what those limits are?
    The number of processes running under your account, the total time your processes run in a given period and the total percent of CPU usage are also monitored.

    In mid 2009, the limits were:
    • 25% CPU
    • 5% memory (eg 400 MB)
    • 240 seconds of CPU time per hour
    • 20 concurrent processes executing

    If anyone (hi, admins) knows if these are the current values, it would be useful information to add to the HRU wiki page.

    Quote Originally Posted by vekou View Post
    • I've noticed that everytime I get suspended, after unsuspending myself, I notice a few spams awaiting for moderation that weren't caught by Akismet. If Akismet is down and spam comments keep flooding in, will this hit the High Resource Limit since the script will probably keep on trying to contact the Akismet server?
    It looks as though Akismet retries every 20 minutes. The retry function itself (take a look at akismet_cron_recheck) doesn't do too much. If there are a huge number of comments, it will have an impact, but shouldn't otherwise. You could add a LIMIT clause to akismet_cron_recheck's $comment_errors query to put a cap on the number of outstanding comments to process at any one go. For example:

    Code:
    		SELECT comment_id
    		FROM {$wpdb->prefix}commentmeta
    		WHERE meta_key = 'akismet_error'
    		LIMIT 20
    You could make the limit configurable via a plugin option.
    PHP Code:
        $comment_errors $wpdb->get_col$wpdb->prepare("
            SELECT comment_id
            FROM 
    {$wpdb->prefix}commentmeta
            WHERE meta_key = 'akismet_error'
            LIMIT %d
        "
    get_option('akismet_retry_comment_limit')) ); 
    You'd also need to update akismet_conf in the plugin's admin.php to both handle changes to the new option and to display a form input for the option. To add the option itself, your best bet is probably a call to register_setting in akismet_admin_init in admin.php. I don't write WP plugins, so there might be a necessary alteration I'm leaving out.

    Quote Originally Posted by vekou View Post
    • Am I making sense?
    Yes. More than many posters.

    Some other thoughts on resolving this:

    Resource spikes (especially ones that only happen every few days to a week) might be caused by spider crawls. Add a robots.txt to limit what spiders access.

    Caching plugins can help, but only if properly configured for your site.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    vekou's Avatar
    vekou is offline x10 Sophmore vekou is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    162

    Re: How do we know which Wordpress plugins causes High CPU Usage?

    thank you very much information. I've tried disabling all the plugins, then enabling one per day. I never experienced any suspensions during that time aside from the "Page temporarily unavailable" screen which is kinda frequent during peak hours. I'm trying to figure out what triggered my suspensions if it was CPU hogging or cpu processing time or hitting the memory limit. For the meantime, I've installed a caching plugin so i can save memory and cpu when my site is not creating cache. yes I know that it can trigger a suspension, but at least it can save me from sudden spikes from spiders and unwanted crawlers.
    We hate people who solicit reputation using their signatures. Click if you agree.

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: How do we know which Wordpress plugins causes High CPU Usage?

    Since it sometimes took a week before being suspended, waiting one day between re-enabling plugins isn't enough time. You'll need to wait a fortnight between enabling plug-ins.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    vekou's Avatar
    vekou is offline x10 Sophmore vekou is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    162

    Re: How do we know which Wordpress plugins causes High CPU Usage?

    okay thanks, but i'll probably disable plugins selectively, the one who are likely to cause spikes.
    We hate people who solicit reputation using their signatures. Click if you agree.

+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: 09-07-2010, 06:04 PM
  2. Favorite WordPress Plugins
    By dWhite in forum Computers & Technology
    Replies: 12
    Last Post: 09-01-2010, 05:19 AM
  3. Replies: 4
    Last Post: 01-19-2010, 06:03 PM
  4. Wordpress plugins
    By ki4kjh in forum Off Topic
    Replies: 2
    Last Post: 10-18-2009, 04:31 PM
  5. Plugins Wordpress
    By carlos30jk in forum Programming Help
    Replies: 0
    Last Post: 09-09-2009, 06:22 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers