Reduce WordPress CPU Usage – Step #1 General tips
Reduce WordPress CPU Usage – Step #1 – General tips

My web site was taken offline recently by my hosting provider (JustHost) due to excessive CPU usage. This was a complete and unexpected surprise as the site has had no problems until then and no new plugins had been installed.
- The first I knew of the problem was when I accessed the site and received, HTTP Error 502 Bad gateway. This means a server (not necessarily a Web server) is acting as a gateway or proxy to fulfil the request by the client (e.g. your Web browser or our CheckUpDown robot) to access the requested URL. This server received an invalid response from an upstream server it accessed to fulfil the request.
My first thought was that my site had been compromised! Maybe some unscrupulous person or persons had inserted a virus or something? But after spending a whole day checking things out, this possibility was ruled out.
- The site typically had over 800 database queries per page, this figure should normally be less than 100 queries per page with typical values being between 20 to 60 database queries per page.
Since then I’ve been trying to optimise this WordPress site and reduce the high CPU usage reported by my web hosting provider. In this article (and possibly more) I’ll post my tips and the solutions I’ve personally implemented. If you’re trying to discover how to reduce CPU usage on your WordPress blog, this series of articles can help you out.
The tips presented today are general tips, the things you should always do with all your WordPress sites. They are the standard things you can do to reduce CPU usage on the server.
General Tips to Reduce CPU Usage On the Server (WordPress)
Tip #1: Upgrade your WordPress to the latest version.
Don’t be reluctant to upgrade WordPress just because it’s already working without problems. Every WordPress update contains bug fixes and improvements, there is no reason not to upgrade.
Tip #2: Update your plug-ins to the latest version.
Unlike upgrading to the latest WordPress version, updating your plugins can be fraught with problems. They might even contain new bugs, especially if you’ve upgraded to the latest WordPress version and they haven’t kept pace with developments. Check the plug-in discussion groups and forums to make sure it’s okay to update.
Tip #3: Update your theme to the latest version.
Update your theme too (especially if you are buying premium themes from providers such as Woothemes. Updates to these are generally kept in line with WordPress). Remember, Themes may also contain ‘plug-ins’, such as the auto thumbnail generation script used by TimThumb.
Tip #4: Remove unused plug-ins.
Do you really need all those plug-ins? Carefully check which plug-ins you are actually using and why. Deactivate/remove all plugins not being used. Many plugin ‘features’ are now implemented in the latest release of WordPress so negating the need for the plugin. Check carefully.
Unfortunately some plugin developers don’t automatically remove database entries (very naughty). Although these entries should not have any affect on your WordPress blog it’s best to remove the entries if only to reduce clutter and improve your database backup size.
You delete these entries manually using phpMyAdmin or with plugins such as Clean Options [http://wordpress.org/extend/plugins/clean-options/] or Plugins Garbage Collector [http://wordpress.org/extend/plugins/plugins-garbage-collector/].
Tip #5: Only activate plug-ins when you need them.
Not all plugins need to be active all the time. For example I use, Broken Link Checker and Search Regex, neither of which need to be permanently active (two excellent programs by the way). Disabling unneeded plugins reduces CPU load.
Tip #6: Cache your WordPress site.
Install a WordPress caching program, I use WP-SuperCache on this site, there are several good ones out there. Check the WordPress plugins pages for more solutions [http://wordpress.org/extend/plugins/].
Caching will, in effect, archive each of the pages on your site. This decreases the dynamic nature of the pages but can significantly reduce the load on the server as the database does not need to be queried so many times to generate pages.
Caching with compression? This tip is a little debateable, let me explain. Caching with compression will save bandwidth but will also add a CPU load on the server the first time compression is implemented. Once a page is compressed any subsequent reads will receive the already compressed page, which effectively reduces CPU usage and bandwidth. The question is, will the additional load on the server outweigh the benefits of the initial compression?
Applications utilising gzip compression will add additional CPU load but WP-Supercache (if I’m not mistaken) generates static HTML files and implements URL rewriting to redirect traffic to the html files rather than dynamic PHP and MySQL which is much more CPU intensive.
Personally, I’ve always found the caching route always benefits the site and reduces the possibility of a sudden spike in visitors bringing your web site down. Try caching with and without compression and decide on their merits yourself.
Tip #7: Reduce PHP/Database calls.
Most of the CPU usage your site will experience is caused by database calls and PHP scripts. Caching your web site helps immensely but some PHP/Database calls are inevitable. My advice, read the documentation for your plugins etc. very carefully and disable any options you don’t need. You generally don’t need to write logs, after all, how often do you read them?
Tip #8: Reduce the number of Widgets.
Cool widgets, such as local weather, time now or number of visitors are nice but does your site really need them? They all put additional strain on the server. Decide which widgets are really required and turn the rest off.
Tip #9: Reduce the theme overhead.
Check your themes CPU usage against a simpler theme such as the defaults that come with WordPress. If there is a significant difference consider changing your current theme to a simpler theme.
Tip #10: Change web hosting provider.
I’m not sure about the next tip, I haven’t tried it, but apparently, changing web hosting providers can significantly improve your CPU usage figures due to the different ways the tech guys and gals configure their servers, particularly with shared hosting. I’ve been told, and I cannot verify this yet (if you can, let me know) Hostgator web hosting is particularly good for CPU usage optimisation.
Tip #11: Research.
There are many other tips and solutions on this subject and I’ll post these just as soon as I can in additional posts. If you have solutions to this problem do let us know.





Thank you for helpful information , my blog is giving many memory errors. Memory limit set to 350M but blog still gives error , I’ll try all your tips. Thank you sir.
This is really difficult, I don’t know what is going on with my blog. I have changed the theme, limited plugins, down from 25 to only 6 but still host is saying it is using excess CPU.
Similar thing happened to me on another site. After I moved the site to HostGator, all problems disappeared. The site uses around 30 plugins now and CPU usage is still 1-2%.
Thanks a lot. I’m facing the same issues. My host suspended my blogs and warned me regarding huge CPU & RAM use. For the time being they’ve re-activated my blogs. I’ve 2 blogs having average 1000+ visitor per day and active 400+ members in each blog who are submitting almost 180+ posts per day on average in both blogs. I’ll try to follow all of your tips to reduce the CPU usage.
Thanks again for this most valuable post.
Keep posting.
Thanks for the comment.
Hi, Today I got my website account suspended (hosted by justhost.com). My CPU usage went up to 22% of 10% allowed. I have a 3-6 images per post and using NextGen Gallery I was wondering if I put images on other blog, remove NextGen Gallery and insert image via URLs, would it decrease CPU?
Ex. if I put images on Flickr or similar to it site and than install plugin displaying those images, would it be better?
Sorry to hear about your problem but are you sure it’s the NextGen Gallery which caused the problem? Inserting image via URLs directly definitely uses less CPU because it doesn’t have to query the database.
Try turning NextGen off altogether (you’ll have no images whilst testing) before you decide to change everything. Install WP-SuperCache and a few of the other optimisations.
If all else fails, try moving to HostGator, JustHost, iPage or one of the many other good hosting providers.
Thanks a lot for the tips. I’m on BlueHost, and my sites performance had really taken a nose dive. After applying these steps, changing my theme, installing supercache and upgraded all the wordpress scripts things have really got much better.
Glad to help.
Hopefully you won’t get any further CPU usage issues.