Wordpress Site shutdown for cpu usage, need help

by 67 replies
78
Ive had many wordpress sets and most if not all use the same plug ins. Ive even had ones with more disk usage and 5X more traffic but for some reason this one keeps getting shut down for cpu usage. ( main index page )

Anyone have any ideas of what I can try or look for to correct the problem? ( Im using reseller hosting from hostgator )
#programming #cpu #shutdown #site #usage #wordpress
  • Are you using a caching plugin? That will help a lot with your CPU usage.

    HostGator recommends this one:

    WordPress › W3 Total Cache « WordPress Plugins

    I've used WP-Super Cache too, but W-3 Total Cache is not as resource intensive.
  • Are you using THAT MUCH plugins? Cause thats a weird case, I have hundreds of WP sites and never had a problem.

    Have you looked into your theme files carefully?
  • Either upgrade your account or get another account and off load the website onto its own account. Or you could get a virtual/dedicated server which should also eliminate the problem.

    How these hosting providers work is that they run a ton of sites on a single computer. When one sites uses to many resources they limit/shut down the site.
  • The reason it's sucking up CPU power is because every pageview on a wordpress blog takes 10-15 mysql queries. If you are getting say 1000 page views/day, that's 10,000 - 15,000 mysql queries throughout the day. That actually puts a lot of strain on a shared box.

    Even if the blog in question gets less traffic, maybe you're running some kind of plugins on it that cause even more database queries to be run on every pageview. I have a blog running that does about 40 queries/page view for example.

    The best thing you can do is look at one of the caching plugins, ideally one that will create static .html files and will force your blog to serve those instead. That way mysql is only touched when you update the site somehow.

    This will take you huge CPU usage down to practically nothing and fix your problem
    • [1] reply
    • Christian, any recommendation? I've been using WP Super Cache but never used the .html function.
      • [1] reply
  • I use godaddy and I have never had a problem, sounds like you need to change hosts
  • ErnieB - how much traffic does this site get? Seems to be a lot of hoops they're making you jump through to fix this.

    Are you able to access you files and everything right now? Can you login to cPanel? If so, do a complete backup of EVERYTHING. HG may just close you account down and you want to make sure you are backed up and can move easily.
    • [1] reply
    • I can access the wp-admin and the site itself ( including forum ) but cannot access cpanel or webmail. I could probably send another email and tell them this and they would grant access but then not release my site, lol. I also have ftp access through filezilla.

      I really want to see if the latest changes I made fix/help solve the problem.
      • [1] reply
  • Try to upgrade your Server, here are the criteria.


    Amount of web space
    File type and size limitations
    Bandwidth allotment
    Reliability and speed of access
    Data Transfer (Traffic/Bandwidth)
    Technical support
    FTP, PHP, Perl, SSI, .htaccess, telnet, SSH, MySQL, crontabs
    SSL (secure server), Shopping Cart
    Email, Autoresponders, POP3, Mail Forwarding
    Control Panel
    Multiple Domain Hosting and Subdomains
  • Get a professional to optimize it, or else get a virtual private server so you can dedicate more resources to it. This is often what happens when you try to solve all your problems by just adding more plugins. Without solving at least SOME of your problems in a custom manner, you're always going to be creating the "splinter effect", in which layers and layers of unnecessary bloat code are added to solve only a limited set of problems.

    My vote/guess also goes to the exec-php in combination with the ebay plugin
    • [ 1 ] Thanks
  • I have multiple queries like this will just the bolded number changed. 35 of the 56 queries were this code below ( just number changed )

    # Call originated from: require, require_once, include, get_header, locate_template, load_template, require_once, wp_nav_menu, wp_get_nav_menu_items, get_post_meta, get_metadata, update_meta_cache, W3_Db->query
    Execution time: 0.000116109848022
    SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (285)

    I dont recognize any plugin names on almost zero queries. One query looks to be maxblogpingoptimizer cause it references ping but the rest are all wp and meta keyword related
    • [1] reply
    • This is the problem right here, not hosting, or javascript, or anything else. This is poorly executed cause what it should be doing (if it should do anything at all) is querying ALL the posts that it needs to work with at the same time in a "IN" clause. Instead it appears that it is running a query for each post that is on the page, to update the meta tags.

      If you have the WP cache (whichever one) running correctly, these pages should not be running ANY php at all. What should be happening is the caching plugin creates an HTML file, and adds it to the .htaccess rewrites to hit the HTML file directly.

      Any sitemap plugin or cacher will update the cache on new posts or new plugin updates and installs.

      *** If this is not happening on your site you have something configured wrong **
  • One thing that I've not seen addressed here is the theme you're using - a poorly-written theme can add a LOT of overhead in terms of db calls and resources used.

    If you want to do a quick and dirty check, load the old Classic theme and check the number of queries.
  • whats the page in question? im willing to bet its throttle time that is getting your site shut down.


    throttle time is usually caused by a bad JavaScript or missing JavaScript that is trying to load.

    open your site in ie, and see if there are any errors on the page ( it will say "done but with errors") or something along them lines in the corner,

    click the error and it will tell you what script is causing the issue.

    i cannot see it being based on database calls. frig most dynamic sites ( including this one) have multiple calls to the database on every page load. I really doubt thats the issue.


    youi still should really consider optimizing your pages, as 150 queries is TOO much , but not anywhere near what would get your site shut down.
  • You can always do without a sitemaps plugin. Wordpress blogs don't need a sitemap, because they use a ping service that tells search engines and directories about new content.

    A sitemap is only useful if parts of your site are not linked to, or you need to tell search engines about new content. Wordpress's ping solves both of these problems.
    • [2] replies
    • Sitemap and other posting updates should have ZERO effect on memory with normal usage (normal traffic).

      After the xml file is updated it's complete. Schedule a cron to post your updates at night/early morning if you can.
      • [2] replies
    • ErnieB,

      I'm in the same boat you are. I'm trying to find the culprit, and here's what I've been doing that seems to be helping:

      I copied the site to a beta site so I could tear it apart.
      Installed GD Press Tools
      DEactivated W3 Total cache (so I could see real numbers - since cache doesn't always optimize a page load & makes it so the numbers aren't consistent)

      Then, I'm looking at my homepage. Everytime I hit refresh, I look at this line (from GD Press Tools) at the bottom of my page:
      "Total number of queries: 89"
      I'll deactivate something & see how many queries it saves. Here's my grid:

      Function - How many queries it uses
      --------------------------------------------------------
      all plugins - 16 queries
      Top Navigation menu - 8
      bottom nav menu - 7
      Blog list of 20 latest posts (homepage) - 59 !!

      Just start tearing your BACKUP site apart, to see what decreases the queries. I deactivated/deleted:
      All plugins
      All widgets
      All menus
      Sidebars (facebook boxes)
      Footer (comments/tag cloud)

      Then (I have a little php knowledge), I was still getting 89 queries on homepage (I started at 298!), I started deleting lines from my template's index.php file. It turns out, there's a php function called: the_post_thumbnail() that uses 3 queries for each post (20 posts * 3 = 60 queries on homepage!)

      That's where I'm at. Still looking for more...
      • [1] reply
  • Yes, in this case when your running it every hour, and probably before it finishes the previous time, you can run into memory problems. If you know FOR SURE that you are not deleting any posts, you could probably optimize it to only append new entries to the end of the files saving TONS of processing.
  • Ive got rid of the sitemaps plugin and the theme I am using is called "Graphene". Ive looked at the site with internet explorer and do not notice it saying any errors.

    As for the query I posted above, it is from a page and not a post or front page so there should be no reference to any posts in my mind?

    It seems that there is quite a few queries at first, but then the cache kicks in and on future page views it is down to a more managable. Isnt that suppose to be how it works?

    I am using the W3 cache plugin and have all the boxes checked to enable all the different cahce and have selected "disk" as the method. No clue really on how to set it up properly

    With the GD tools, will it display the queries for all visitors at bottom of page or just me? I dont have it currently set to display them but anyone can view the site ( and I can turn it on if you want ) spartanbloks.com
    • [2] replies
    • No that's browser cache, not server cache. Cache should be already "primed" before the first visitor. Unless different plugins work different ways, caching the first visitor visit "priming" the cache.

      I haven't looked into how each one works at the code level.

      JavaScript has nothing to do with this, JavaScript is run at the client's computer.

      What plugins do you have creating/updating meta tags?
      • [2] replies
    • Are you sure your just aren't getting too much traffic for your current hosting package. Took a look at the site, and its really not all that bad, things could use some optimizing, but I don't really think its so much the page, but the traffic/bandwidth and your current host.
      • [1] reply
  • I've heard that your permalink structure can cause problems, as well.

    If you use a very short structure -- such as postname alone -- it works the database hard and slows it down if you have a lot of content.

    John
  • I agree with the above statement 101%!

    I say it and see it all the time.
    Along with avoid plug-ins unless it is essential to the functionality of the site.
    Then if you use such a plug-in, check the code(is it properly coded), if you can't read code, read comments about it ect...
    Find out if it functions correctly or has issues, most have issues, including loading extra files, multiple queries, etc....

    A lot of themes out there are awful as far as code also.

    Optimise the site itself first, theme, files, plug-ins, scripts, http requests...

    Recent functions from WP such as the_post_thumbnail() can have heavy loads as they are new and not optimal yet. Be careful when using them.

    The menu system is another feature that I benchmarked and is high on queries.
    Fine if you have one menu, but some themes use this everywhere and it can get heavy quick.

    Widgets can also have some high queries.

    It doesn't take long to over load a site when not paying attention to what it is doing on the backend.
    • [ 1 ] Thanks
  • Ernie, I'm new & cannot reply to your PM. If you PM me your email address, I can reply to your original PM.
  • another good extention ( for chrome) is monster, it analyzes web pages and suggests ways to improve their performance based on a set of rules for high performance web pages.

    I use it in extension to firefox and it works well
  • @DavidBratvold Code analysis gets a lot more technical than opening Task Manager.

    FireBug -> Net tab for HTTP requests and header, etc....
    PHPUnit & CodeCoverage for PHP unit tests (Very advanced)
    WebGrind for basic PHP coverage, process times etc... Works well.
    XDebug PHP debugger for debugging
    MySQL WorkBench can help with showing database performance

    And there are many others...

    For plug-ins make sure you use WP's standards.
    Always make a hook for JavaScripts and CSS in your plug-ins so others can disable them and add them the way they want without editing your plug-in.
    This makes it possible to compile these items to lower requests.

    Check the queries, how many database connections.
    HTTP requests, limit them as much as possible.

    Everything on your server/site uses resources...
    Every image causes a request, what do you think delivers that request?
    The server.... Apache httpd.

    It all causes load on the server.
    • [ 1 ] Thanks

Next Topics on Trending Feed

  • 78

    Ive had many wordpress sets and most if not all use the same plug ins. Ive even had ones with more disk usage and 5X more traffic but for some reason this one keeps getting shut down for cpu usage. ( main index page ) Anyone have any ideas of what I can try or look for to correct the problem? ( Im using reseller hosting from hostgator )