
I’ve been trying to optimize this WordPress blog because of the high CPU usage reported by my web hosting. I’ll post a few tips that I do personally on this blog and hopefully if you are trying to find out on how to reduce CPU usage on a WordPress blog, these series of posts can help you out.
One thing that I’ll be writing today are general tips (that you probably have already heard/seen somewhere else) that you can do to reduce CPU usage on the server.
General tips to reduce CPU usage on the server (WordPress blog)
- Upgrade your WordPress to the latest version if you haven’t.
You are probably reluctant to upgrade if it’s already working but note that every WordPress update always contains bug fixes and improvements so there is no reason not to upgrade. - Update all of your plug-ins to a newer version.
They might contain bug fixes (or new bugs!? Check the plug-in discussion to make sure that it’s fine to update). - Update your theme files too (especially if you are buying premium themes, sometimes the author has made an update to your theme). For example, I found out that this blog’s theme, Arthemia Premium, was updated with some optimizations. Also the auto thumbnail generation script used by the theme, TimThumb, also had an update that I applied straight away.
- Do you really need those plug-ins?
I know the plug-ins are nice. I had like 40 of them before I did some cleaning up. Now it’s down to 21 (still a lot but I can’t be apart with them yet). - Are you sure you really need those plug-ins?
Again, after you deactivate “unnecessary” ones, try again. This time though, try to look for a feature in a plug-in that is already incorporated on your WordPress version. This is harder to find and require you to do some research, but sometimes a newer version of WordPress has already covered what a plug-in is doing - Only activate plug-ins when you need them.
For example, you don’t need to activate a Theme previewing plug-in if you are not planning to change a theme. You don’t need to activate a WordPress database backup plug-in if you are not auto scheduling a backup, and so on.

- Install WP-SuperCache if you haven’t. Find out how WP-SuperCache saved my blog from the StumbleUpon effect. Also, turn on the WP-SuperCache compression when possible. (Update: Compression will save bandwidth but will actually add to a CPU load on the server. Thanks to Mister Hobbes on the comment section).
- Reduce PHP/Database calls as much as you can.
Most CPU usage is caused by the number PHP and database calls. Using WP-SuperCache helps this tremendously but sometimes it can’t be helped that your blog still has to do some PHP/Database calls. If you can reduce it though, do it. For example if a plug-in allows you to set an option whether to write a log or not (like number of spam comments caught, etc), then disable it. This will reduce the number of database insertion/update calls. - Reduce the number of Widgets and other components as much as possible.
Although putting a weather widget or other widgets are cool, do you really need them? Besides cluttering your blog and turning visitors off, it can also put a strain on the server. Turn them off! - If all else fail, switch to a simpler theme and check the CPU usage again. I’m quite sure that my theme is a bit heavy (especially with the dynamic thumbnail generation) but before I change it, I wanna fight til the end first!
Unfortunately there are many other tips (you can try Googling for more) but these are the basic ones that I applied. There are other specific things that I do, but I’ll write it on separate posts instead. I’m also interested to find if you know how to block spam comments before they even got inserted to the database. I’ve tried the htaccess blocking codes but they gave me blank screens when I tried to access my posts
Don’t miss my other Reduce WordPress CPU Usage tips that can be found on my blogging guide series page.
UPDATE: After all these troubles, I found that going for Hostgator web hosting was the best option for me. I have tons of plug-ins now with thousands of visitors a day on a shared hosting. No complains from Hostgator and the CPU usage is only 0.1% when I monitored it.



{ 56 comments… read them below or add one }
Does your theme generate thumbnails each pageview or are they just created once? It looks like it is dynamic from the url, and you might want to fix that, maybe by adding some sort of cache for the same generated images, etc.
Well it is using a script called TimThumb.php which is an open source one. It already has some caching mechanism to check whether the images have already been generated or not. I’m sure it’s called per image which explained why the usage can shoot to the roof.
“Also, turn on the WP-SuperCache compression when possible.”
bu turning on compression, your CPU usage will increase whereas your bandwidth will decrease. Compression = zipping, imagine zipping every file in your computer and when you need to access them, you unzip them, this may increase your storage space at the expense of processing speed.
You are very correct on this matter, MisterHobbes. I’ve updated my post according to your insights (and I just noticed that I mispelled the title as well *doh*)
Hm maybe it was the reason why my CPU suddenly jumped so high earlier and my account was disabled temporarily as a result
Not quite true… there is gzip compression which does add to CPU utilization but wp-supercache isn’t explicitly gzip compressions. Basically it generates static HTML files and uses URL rewriting to redirect traffic to html files rather than dynamic PHP and MySQL which is much more CPU intensive. I work at a hosting company that calculates and charges based on CPU usage and wp-supercache is one of the BEST ways to reduce CPU consumption on a WordPress site. Seen it work 1000 times. I’m actually browsing this site looking for a good option for reducing the CPU usage of timthumb. Anyone have a good reference on setting up caching for that?
As far as I remember back then when I used my old theme with timthumb script, it already has its own caching mechanism.
I remember looking at the code and found references about the caching (cache the thumbnail image on a cache folder and serves that instead of resizing the image with a PHP code)
I like to disagree with MisterHobbes’ comment. Its logical to say zipping increases CPU usage, but that is only once. When the same page is accessed again (say another 100 times), the zipped content is sent directly and hence no need to process the compressed data (js,css,images) again, which means effectively it reduces CPU usage
Unzipping will be done by the browser and not the server. I have written a detailed post on the same but the post is scheduled to be published on June 2nd
yes, unzipping is done by the browser. However, the server needs to zip the file before it feeds the browser the gz compressed version. Compressing files is still done on the server side everytime someone visits your site, unless you have some sort of cache for compressed files.
What say you Michael Aulia? did your server load reduced after disabling compression?
It’s hard to tell since I don’t have access on the server and have to reply on the support team to tell me whether it has any effect or not
I guess once a cache is cleared, the plug-in has to compress the post again, meaning it will certainly take some cpu resources to do that. If you have lots of posts and cache is being cleared often, then it can be a hog to the server.
@Raju, pertially you’re right but in case of some WP Plug-ins like Google XML sitemap Generator, if you’ll enable the gzip sitemap option then everytime you update your WP by any means (new post, updates, new tags, categories etc/) the gzip will process in backend. In case of a blog having 500+ post and user base of 100+ and atleast 20-30 active user, then the gzip feature will be processed in every 10-15 minitutes to keep update the Google XML sitemap files. Hence it’ll be a very big headache for the owner or admin of the blog. This way MisterHobbes is very much correct. Wish you happy blogging.
My site got down lot of times but it is due to lot of visitors hitting the site.
Thanks for the points. WIll note it downl.
The first thing which i’m doing after writing this comment is to check whether i really few plugins which i fixed up there in my WordPress admin.
yes there are couple of plugins which i don’t need this time, let deactivate them to reduce WordPress CPU usage. Thanks for the tips michael.
If only we have unlimited CPU power and every one of our reader has a T1 connection, then I guess we can use a hundred of our lovely plug-ins
I hardly use 6 plugins on my blog right now… I even modified some of them so that they doesn’t make unnecessary php calls…. Simple theme always has lower burden on the CPU..
Yeah, you are right. Although the plug-ins that I use don’t have anything to do with the theme, I agree with you on using a simpler theme. I’m switching temporarily in about half an hour to a simpler theme momentarily.
I will suggest try DP optimization plugin from Yoast..That will also help here..
Will look for more optimization tips from you..
I also used wordpress for one of my websites. I find cms made simple is better than this one. You may try it.
@MisterHobbes,
“Compressing files is still done on the server side everytime someone visits your site, unless you have some sort of cache for compressed files.”
I guess we were talking about enabling compression option of wp-super-CACHE plugin, which caches the compressed files as well.
@ Michael Aulia,
You are right, once cache is cleared, compression will happen again. I assume there will be decent traffic in-between the clearings. Why would someone clear the cache often if he/she doesn’t get enough traffic to make use of the cached files?
Hi Michael,
I have been trying to go through all the plugins I had installed and remove the ones I don’t really need. At one stage, I had over 25 plugins installed, but that number is well below 20 now.
I think the Super Cache plugin is a must for any website, no matter small or big. this helps out a lot and you can definitely see the difference, oh well I can.
George Serradinho´s last blog post..Transform your pictures with PhotoFunia
Now that I’ve moved my hosting and can actually see the CPU usage, I might increase my plug-in numbers just a bit more heh heh
Thank you for this useful post. I’m wondering how to reduce PHP/MySQL queries, and don’t know how
I am having the same issues and my site was temporarily disabled. The hosting company wants me to purchase a dedicated server but that is NOT an option so I am doing a lot of what is suggested here. I am a bit confused about the compression in WP-Super Cache. Will this or wont this help? And as far as reducing the PHP/MySql queries I have no clue where to start.
Mark
Hi Mark, sorry for my late reply. Make sure you check my other posts on how to reduce the cpu usage (you can access it through the Blogging guide series page on top).
The compression definitely reduces the bandwidth use but it will increase your CPU usage when it needs to compress the files. So in this case, disable the compression mode if you are experiencing a high CPU usage, but it may not be much
WP Supercache doesn’t work on some shared servers. Try Hyper Cache, it’s easier to configure and works like a charm. Unfortunately gzip ain’t supported on Hostgator shared servers. I would have used it and set the cache to clear after 36 hours.
With regards to the use of too many plug-ins, immediately I find an alternative, I uninstall them.
Hm I remember enabling the gzip/compression option on supercache and it worked fine on HostGator. But I guess I didn’t test thorough enough
It was the damn gzip compression i guess that triggered the throttling for me. I had forgotted i modified index.php in wordpress to gzip everything.
Now wonder my CPU cycle went high now i knw
or maybe time to move to a different hosting?
The is more than 1 hostgator as in eat your money and upgrade, upgrade, you need a vps, you need a dedicated server. Do you ever wonder whey all they know is upgrade to get in your pocket and never do much on their side to make their damn systems run right?
Well that’s what most business do. Squeeze more money from the customers
Recently one of my website banned by my host because of excessive CPU usage, and i found this post , think it will help, am going to try this tips. lets hope for the best.
Hi Jay, I’m also facing the same issues for last few days. Please let me know your experiences. I’m keenly interested to have your valuable suggestion in this regard. How is your experience? Please update me ASAP.
Hi Agarwal, make your WP install updated and you have to check all your WP plugins and update all and not compatible plugins you have to remove them, and install WP-SuperCache for caching if you experience excessive visitors.
thanks a lot , i m on bluehost too , and my site performance has gone really bad , i have applies few steps from here
changed my theme and installed supercache and upgraded all the wordpress scripts
Hope you won’t get any of that cpu usage issue anymore
But I like the plugins!!!!
I know… the best way is to move to a different web hosting. After the move, I even use more plug-ins now!
well it is really difficult part , i don’t know what is going on with my blog i have changed theme,limited plugins , i used to have 25 now only 6 are working but still host in saying it is using cpu in excess
Same thing happened to me, buddy. After I move to HostGator, all problems go away. I even use around 30 plug-ins now and CPU usage is still 1-2%
Hi,
Today i got my website account suspended (hosted by justhost.com).My CPU usage went up to 22% of 10% applowed. I have a 3-6 images per post and usign NextGen Gallery i was wondering if i put images on other blog, remove NextGen Gallery and insert image via urls, whould it decrease CPU?
Ex. if i put images on Flickr or similar to it site and than install plugin displaying those images, whould it be better?
Alex
Ouch, sorry to hear that. Are you sure it’s the NextGen Gallery which caused the problem? I’m not sure how it works but inserting image via URLs directly definitely uses less CPU because it doesn’t have to grab the URL info from database
Try turning it off altogether for a few hours (yes, this means you’ll have blank images on the posts, but temporarily) before you decide to change everything. Or install WP-SuperCache on your blog and a few other optimizations: http://www.cravingtech.com/how-to-prepare-wordpress-blog-for-a-huge-incoming-traffic.html
Or if all else fail, it’s your hosting that sucks, sorry to say. I was in this boat and moved to HostGator. Have lots of plug-ins without any problems now.
I used to run my site on justhost.com and I was suspended several times, last time I was suspended due to 40% CPU overload. I have installed W3 Total Cache and DB optimizer and bad behavior , also I have about 5 basic plugins. my site has more than 15 posts on single page and I think that may be the problem. you can see it here [url removed - porn site related, sorry!!]
Few day ago I have moved to vps:
Webspace 30 GB
Port 100Mbps
Transfer Unmetered
Server Quad Core/i7
Dedicated RAM 512 MB
Burstable RAM 768 MB
And now when I have more than 50 visit my site just stop working :S
Daily I have about 5000 visits and that hardy can pay my expensive vps
All images I hot at free image hosts.
I would really appreciate if someone can help me with this. I would consider to pay if someone have really good solution.
Thanks
im still suspeded , i google and see this page , i think you should set 6 post in index page , i have near 1000 visit per day , shared hosting , lunarpages , in last year i dont get any suspend and i have more visit than now . I dont know why …
I think that best way to solve this problems is to find someone who will optimize your mysql and set your w3 total cache
My site was not working until I have set it, I have payed 70$ for this job but I’m happy
I think thw best Way to Solve these problem is…….
- Remove unnecessary Plugins
- Optimize Database
- Install WP-Super Cache Plugin
-Remoe SPAM Comments
If isnt successful
Buy a Semi Dedicated or dedicated Server. I too was having the same problem with (http://shafprince.com) my website.
Not really. I went for changing my web hosting (still on a shared account). Best decision ever. All problems go away in an instant
Thanks for the tips but still
Server load showing 2.62 (6 cpus)
Hi, there any teh best way how to optimize WP database?
MDS recently posted..AVERT Software Free Antivirus
Hi,
Great tips,thank’s a lot.. this is one of the best answer i found on google so far.. thumbs up!
Thank you for helpful information , my blog is give many memory errors while I set memory_limit to 350M m but blog still give error , I’ll try all your tips .
Thank you sir
thankyou.. i am going to install cache plugin to my sub-domain site
Thanks a lot Michael. Its really the best tips and tricks I’ve found over the net regarding WP CPU USAGE. I’m facing the same issues from yesterday(Oct 1, 2011). My host also suspended my blogs and warned me regarding huge CPU & RAM use. For the time being they’ve re-activated my blogs but still Internal Error 500 showing time to time. 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. Now I’ll try to follow all of your instructions as well as tips to reduce the CPU usage. Hope I’ll be tension free soon. Thanks again for this most valuable post. Keep posting… May God bless you and all the best….
Thanks for the comment, good to know!
In the end, most likely it is your web host as it happend to mine. I spent days and weeks maybe trying to fix this issue. In the end, after migrating to HostGator, everything went well up til today (I have around 4,000 unique visitors now and all is still well)
Nice to hear from you Michael. I’ll also try to fix the issue as per all of your tips and then surely get in touch with u regarding HostGator service. Thanks a lot again.
Thanks Michael
Just to clarify, installing WP-SuperCache on its own won’t hurt you CPU stats, but activating the compression feature within WP-SuperCache may well do….?
Hope I’ve got that right.
I’ve had this happen to me this week and it is all very frustrating….
From what I understand, when you activate the compression tools, the server will certainly do some processing to compress the articles. This will add some overhead to the CPU usage (not sure how big or small though)
I have been on hostgator for years.
Ever since I started using wordpress for my website chrisroubis.com I have been having CPU issues as my website got popular.
Reseller shared hosting limitations kept shutting down my website because of excess cpu usage.
Then I signed up to a VPS hosting.. still same problems.
Now signed up to a dedicated server, no more downtime because of CPU limitations.
{ 3 trackbacks }