• mihaim

    (@mihaim)


    Hello,

    Long time reader, first time poster.

    I have a problem with my WordPress installation. I even got banned from shared hosting for this and put my own server and still have this problem. Apache has a very high CPU usage (it makes 100% of 1-3 processes) on a 1.5GHz box every time I get a dynamic request on the server.

    My DB is 30MB and have about 4000 pages (articles + pages) on the website.

    Without cache the site works really bad (I use wp-super-cache).

    I tried updating WordPress (I’m on 2.3.3. now. 2.5 blocks my server completely with a single process using 100% CPU and the older version (2.0.x, etc) work in a similar bad way), disabling all the plugins, enabling cache but didn’t find a way to get decent CPU usage from Apache (MySQL works OK. Apache is the problem).

    I use now an Ubuntu Server with LAMP chosen at install. The old hosting (which banned me for exceeding CPU quota) was GoDaddy. Also I should mention that accessing the permalinks page (in options) takes 30-100 seconds, time in which the CPU stays at 100%.

    Thanks.

Viewing 15 replies - 31 through 45 (of 71 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    On a blog I have with around 90 posts, my rewrite_rules has a value which is 6500 bytes in size.

    Do you happen to have a lot of Pages (instead of Posts)? That might be the bottleneck. Since the rewrite rules have to be loaded from the database every time, perhaps increasing the query cache on the database would improve performance?

    Thread Starter mihaim

    (@mihaim)

    A few a couple of hundred pages compared to a couple of thousand posts.

    The rewrite_rules is so large that I blocked the whole PC saving the text from it (copy/paste) on a Core2Duo 2GHz laptop…

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Well, that could be a problem. Might try going to the settings->Permalinks page and updating them. That should force it to regenerate the rewrite rules, might clean out some of the crap if there is any.

    Alternatively, you might consider using some form of persistent memory cache. More info on how to do this, along with some history, is here:
    http://neosmart.net/blog/2008/wordpress-25-and-the-object-cache/

    Thread Starter mihaim

    (@mihaim)

    🙂 If you follow the topic you see that if I go options – permalink I put the server down for up to 100 seconds, time during which one or more Apache2 servers stay at 100% CPU.

    At this very moment I consider deleting everything inside rewrite_rules and regenerating it using options – permalink. Hope that works and doesn’t break my DB.

    Thanks for the link, but the problem is so bad that right after I put WP 2.5 the site was in such a bad state that every single Apache process (doing anything dynamic) was keeping CPU at 100% that even after a server restart (in the very next second) I was unable to access my homepage. Had to put back the old DB and the old files from 2.3.3.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Well, if it makes you feel any better, when you go to the permalink page and click update permalinks, it flushes out the rewrite_rules option from the database. So deleting the row probably won’t have any ill effects other than breaking the site until you update the permalinks.

    Thread Starter mihaim

    (@mihaim)

    I see… Do you know of anything that can take so much memory in a normal wp-options table?

    Just noticed at the end of the wp-config that I have multiple instanced (to a total of 5) of rewrite rules.

    Later Edit: Did some deleting and optimizing on wp-options and got that from 19MB to 1.9MB. Will post the results.

    Later Later Edit: Apache2 uses just like before 100% CPU with 1-5 processes. Nothing solved.

    Later Later Edit: If [1]=>
    float(8.98838043213E-5) is the value in ms, then the this is the biggest value (under 10 ms) with only 3 taking around 10 ms and the rest way less.

    Thread Starter mihaim

    (@mihaim)

    Cleaned the wp-options of rewrite_rules and the site is fast (maybe 5 times less CPU needed). The problem is that if I open options-permalink (which is opening as slow as before) it creates a few tables with rewrite_rules in wp-options which put things back after the cleaning of the DB. I get 6 Apache2 processes using each 16.7% of CPU when opening that page.

    I just deleted them and without accessing options – permalinks it made another 5 mod_rewrite entries in the DB using tons of CPU and 8MB of entries there. The entries made there are identical.

    I keep looking around the DB and keep finding new rewrite_rules entries. I keep deleting them (and keeping 1) and they keep showing up. What part of WordPress can create this entries?

    Again, deleted every of rewrite_rules, kept only 1, site works great. If I open the permalinks page again I will get a 10MB wp-options with about 5 rewrite_rules pages and a lot of CPU time to create them… Is there a way to lock the current rewrite_rules to be the only one that can be created?

    By doing this optimizations and cleaning in phpMyAdmin I got the DB to just 17.7MB from 30MB. It really makes a difference.

    I am at the traffic peak (daytime in the USA) and have a load average of under 0.5 usually. The performance is greatly improved. Just that I still have the problem with the platform making itself to perform really poor…

    Brain916

    (@brain916)

    Hello,
    I am having this same problem.
    My website keeps dieing out, and Apache is sky high.

    What should I do?

    dodge107

    (@dodge107)

    Hi all,
    I had the same problem, high CPU and memory usage.

    Found the cron section in wp-options table had gone bad, deleted it and site picked up again. The cron gets recreated automatically.

    Hope this helps

    Thread Starter mihaim

    (@mihaim)

    Glad to see that answers appear after I figured out the problem myself (with tips from other users). The conclusion is that you should check your DB often for anomalies, for example an unreasonably large wp-options, etc. Optimize your db, delete comments from akismet, check the tables in wp-options, update wordpress, etc.

    microkid

    (@microkid)

    Thanks all, this is a very useful topic.

    @dodge107 – What do you mean by the cron section of the wp-options table? And how can you tell it’s gone bad?

    @ MihaiM – What would you consider a “large wp-options” table? And what other anomalities should I look for?

    Thanks again.

    Thread Starter mihaim

    (@mihaim)

    If it’s too large is bad. WP-Options should be around 1MB (that’s what I have with over 5000 pages). If it’s larger than that or has more than one instance of cron or permalinks or rewrite_rules, etc. it’s bad and you should delete them after you have made a proper backup. Also optimize the tables when you finish editing them. Use phpMyAdmin for all there processes.

    P.S. Imagine how useful was for me to find the solution after I got banned a few times from shared hosting, killed my server with 0.5 requests / second, etc.

    dodge107

    (@dodge107)

    Glad we got to the bottom of this!

    Shell we log this as a bug, save the masses from blog destruction?

    cuzoogle

    (@cuzoogle)

    Ok excuse me for not picking the solution out of all of these great posts.

    I read them over a few times and still could not find the “how” of fixing this.

    Since upgrading to WP 2.5 I have had terrible problems.

    I even had a friend who knows what he is doing, do a clean and fresh install for me.

    I have been shutdown 3 times now by Host Gator for exceeding 25% CPU usage. I have very small, personal blogs.

    Does this make sense?

    The problem from my eyes is happening with some glitch where I am getting a script error when trying to start a new post. Everything hangs and is very slow.

    It happens in IE and FF but I can use Safari without it.

    Again I have had a few people look into this and they have not figured it out yet.

    It is extremely frustrating because it all started when I upgraded. Never had a problem before that.

    http://cuzoogle.com is my main blog……it was down for 2 days this week because of the CPU usage. It got resolved enough to get it back up but I still get the script error.

    http://chocolatedogblog.com/
    http://michaelcusden.com/

    are the other two that are currently down for over usage. They only get like 100 views a day.

    They don’t have the script error and I am currently trying to find out from Host GAtor what is up.

    With the small amount of traffic I get I don’t see how I can be using that much CPU time.

    I have tried removing all plugins, trying it out with default theme and the script error is still there.

    http://cuzoogle.com/wp-content/uploads/2008/04/errorscreen1.gif

    I am not a coder, I don’t mess around in my backend, I just upgraded to 2.5 and the night mare started.

    if anyone has any idea please let me know.

    dodge107

    (@dodge107)

    That has to be javascript – php will not output an error like that! Its all server side.

    Check javascript settings?

Viewing 15 replies - 31 through 45 (of 71 total)
  • The topic ‘Very High CPU Usage’ is closed to new replies.