The following documentation is extremely useful if you want to keep your site running optimally. *Note, while I am aware of the steps below, I did not write the below article personally though I did do a lot of revision to it.*
1. Repair and Optimize. Your database has been updated a lot of times in the last day, whether you’ve posted or not. There’s a lot of chance for errors there, so you might as well check. If you have SSH Access, use the following SSH command:
mysqlcheck -auto-repair -u`whoami` -p -A -o
Otherwise, the process can be completed through the cPanel.
a) Under the Databases section, click on PHPMyAdmin.
b) Notice the table that appears. This contains all your posts, categories, comments, blogroll links, users, etc.
c) Scroll to the bottom. Click on Check All.
d) To the right of Check All you’ll find a drop down. Choose Repair
e) Repeat the process and choose Optimize from the menu.
(Note that you really only need to do this if you have a lot of overhead in your tables. Check it often.)
2. Deactivate plug-ins you don’t use, don’t absolutely need or don’t want. Remove them entirely from WordPress’s plugins folder (located in wp-content/plugins) after deactivating them inside WordPress itself. Plugins are the cause of many problems.
3. Switch to Fast CGI (Or switch from Fast CGI, sometimes, too)
Login to your cPanel
Click on PHPConfig (under Software/Services).
Select the PHP5 FastCGI button.
Save. (Note: According to WordPress documentation this will speed up WordPress, however, this can sometimes be counterproductive. If needed turn it back to php5.
(Note, all the documentation says this will dramatically speed things up. This has not always been my experience. Still, try it.)
4. Close any Post Writing Pages when you’re not using them. WordPress will Auto-Save and it uses server resources and builds up CPU usage.
5. Avoid plug-ins or widgets that go out and get RSS feeds. These include the RSS widget and those that look for Twitter tweets.
5.5 .- Remove any old revision posts to clear up database size.(Backing up the database before doing this may be a good idea). See the following for the needed SQL query: http://www.mydigitallife.info/2008/07/22/how-to-delete-existing-wordpress-post-revisions-storedsaved/
6. Turn off the Formatting Options in Settings
In WordPress, under Settings->Writing uncheck both Formatting options. Especially turn off “WordPress should correct invalidly nested XHTML automatically”.
7. Don’t post via e-mail/word. Write your posts in the Write interface and copy/paste it into Word when you’re done or when you take a break. Don’t make WP spend time parsing your Word file.
8. Use Summaries in Feeds. Under Settings->Reading, select use Summaries in Feeds.
9. Use less posts on each page and less Items/Feed. Log into WordPress, go to Settings->Reading, then Reduce the Post/Page and Items/Feed values. Also try the following plugin to help optimize the way your posts handle queries: http://wordpress.org/extend/plugins/efficient-related-posts
10. Under Settings-Discussion, turn off any e-mail notifications you don’t need; especially redundant ones. If you go to your blog often, don’t worry about having it e-mail you for comments. Just turn that off.
11. Install http://wordpress.org/extend/plugins/robots-meta/
In the plugin’s settings noindex/nofollow the things you don’t want/need Google to look at. Turn off date Based Archive, At the least, nofollow/noindex it. Nofollow/noindex (or disable) your author archives(The author archivesmay help boost your search engine ranking slightly. While it is helpful to have this disabled, consider whether you want better performance or possible slightly better search engine rankings)
Redirect “external search results” to your homepage. This prevents people from linking to your search results, which would cause a search every time someone clicks on the link.
12. Use Google Search. This will let Google do the CPU work for your searches, gives you a surprising amount of credibility and brings you money. (adsense.google.com)
13. Reduce image/video/flash/etc sizes. Use Photoshop, Gimp or Fireworks to reduce the image size. Google.com has tutorials.
14. Reuse images. Upload it into a folder inside wp-content (using FTP) called “MyImages” and manually link it. See w3schools.com with coding help.
15. Use a Category Only RSS feed, rather than requiring everyone to use the main RSS Feed. To do that, use a link that looks like: http://MyBlog.com/category/CatagoryName/feed/. This way when someone only wants to hear about “My Dog”, they only hear about the dog and you only get queried for one category instead of all of them. You can put these in as a text widget (be sure to code it manually).
16. Use optimization plugins:
-Use a caching plugin, either the WP Super Cache plug-in, or W3 Total Cache, especially when expecting a large amount of traffic. Find these at: http://wordpress.org/extend/plugins/wp-super-cache/ and http://wordpress.org/extend/plugins/w3-total-cache/. You may need to turn it off while editing posts (or clear the cache from it’s Settings page) as it often doesn’t refresh a page after an edit.
-Use WP Minify to combine and compress CSS and Javascript. Find at: http://wordpress.org/extend/plugins/wp-minify/
-Use WP Smush.it to compress images. See: http://wordpress.org/extend/plugins/wp-smushit/
17. Reduce the excess in your CSS, JS and PHP. If you’re doing things that are redundant (e.g. telling a Strong tag to be bold) take it out.
18. If you have the option, use arrays to populate your queries rather than calling them repeatedly to grab different pieces of information.
19. There may be a plugin or a problem left over from a plugin or something along those lines which causes your wp-cron.php to continually update. Read the following on how to disable it: http://wordpress.org/support/topic/124485?replies=13
20. Update. Update. Update. WP updates often have security and feature fixes as well as performance fixes. They also have streamlined code. Use it.
The following article has some discussion in regards to CPU as well: http://wordpress.org/support/topic/164456?replies=61
The following caching tip is taken from
http://www.askapache.com/htaccess/speed-up-your-site-with-caching-and-cache-control.html#caching-with-mod_headers
Caching with both mod_expires + mod_headers
# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0
# Set up caching on media files for 1 year (forever?)
<FilesMatch “\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$”>
ExpiresDefault A29030400
Header append Cache-Control “public”
</FilesMatch>
# Set up caching on media files for 1 week
<FilesMatch “\.(gif|jpg|jpeg|png|swf)$”>
ExpiresDefault A604800
Header append Cache-Control “public”
</FilesMatch>
# Set up 2 Hour caching on commonly updated files
<FilesMatch “\.(xml|txt|html|js|css)$”>
ExpiresDefault A7200
Header append Cache-Control “proxy-revalidate”
</FilesMatch>
# Force no caching for dynamic files
<FilesMatch “\.(php|cgi|pl|htm)$”>
ExpiresActive Off
Header set Cache-Control “private, no-cache, no-store, proxy-revalidate, no-transform”
Header set Pragma “no-cache”
</FilesMatch>
Caching with mod_headers
# 1 YEAR
<FilesMatch “\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$”>
Header set Cache-Control “max-age=29030400, public”
</FilesMatch>
# 1 WEEK
<FilesMatch “\.(jpg|jpeg|png|gif|swf)$”>
Header set Cache-Control “max-age=604800, public”
</FilesMatch>
# 3 HOUR
<FilesMatch “\.(txt|xml|js|css)$”>
Header set Cache-Control “max-age=10800″
</FilesMatch>
# NEVER CACHE
<FilesMatch “\.(html|htm|php|cgi|pl)$”>
Header set Cache-Control “max-age=0, private, no-store, no-cache, must-revalidate”
</FilesMatch>
Caching with mod_expires
ExpiresActive On
ExpiresDefault A0
# 1 YEAR
<FilesMatch “\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$”>
ExpiresDefault A9030400
</FilesMatch>
# 1 WEEK
<FilesMatch “\.(jpg|jpeg|png|gif|swf)$”>
ExpiresDefault A604800
</FilesMatch>
# 3 HOUR
<FilesMatch “\.(txt|xml|js|css)$”>
ExpiresDefault A10800″
</FilesMatch>



24 Comments until now
You post helped me understand WordPress more effectively. Expecting more like this posts…
Thank you
This is one great post. I will definitely implement thoses steps
very useful information for wordpress shared host accounts.
awesome article i read it thoroughly and did required changes from my end thats help me alot. Thanks
Just as an additional tip, another WordPress user commented the following, which is very useful:
“I host a dozen sites with Bluehost with 25,000 views a day and have experienced the same problems in the past but recently resolved it. Last week, my site was being throttled 2.5 hours a day, now the throttling is down to 50 seconds a day.
That comes from two major changes, I moved the RSS feed off the site and redirected it (the RSS feed isn’t cached and accounted for most of my CPU usage). http://helpfulcoder.com/38/offload-or-cache-your-wordpress-feed-for-maximum-performance/ Then I also updated the Super Cache settings to preload my content once a day http://thisismyurl.com/81/gain-valuable-seo-power-with-caching/ which dropped my CPU usage to almost nothing across the sites. ”
See also: http://www.jtpratt.com/wordpress-file-include-hacks/
Hi there,
Its a very interesting post but sadly i am not a very technical person. So i was hoping that you can take a look at my site and probably help me sovle my problem.
The problems that i am facing is
1. Error 324
2. Slow connectivity to my site, when all other site, e.g Facebook & youtube is ok
3. I get this msg and cant access my pages “Not Found Sorry, but you are looking for something that isn’t here”.
Please help
Thank you
Error 324 is an error in Chrome. See: http://superuser.com/questions/99792/what-is-error-324-is-it-related-to-google-chrome-or-verizon-webmail
I can replicate the slow connectivity to your site, unfortunately there is really no way for me to know what is causing it. Start by setting your theme to the twentyten theme, and then disable all of your plugins by renaming your plugins folder. You can find this folder within your wp-content folder.
I didn’t see any 404 errors on your site. Perhaps if you can list how to replicate it, I might be able to give some tips.
Regardless of what the underlying issues are, the information in this article will help you optimize your sites.
Great information, i’m not good in english, pls help me, my site http://www.actresshotpics.com, every time my site is suspended from my hosting server, reason my site exceeded 10% cpu memory. how to reduce cpu memory and how to calculate my cpu memory in my site. pls help me SIR, urgently,PLSSSSSSSSSS
Great post! Automatically linked!.
Thank you.
Rani, This whole article shows you how to deal with CPU usage problems. Go through each step in here and it should be able to drastically improve your performance. Check out the comments here and on http://wordpress.org/support as well for other suggestions.
If you have specific questions, feel free to drop in another comment with them and I’ll see if I can advise further.
If you’re interested in paying someone for support, see: http://vip.wordpress.com/support/
Good luck.
Really nice article and very useful, hopefully I can fight back CPU throttling with this tips
Thanks a lot for your post.
I have serious issues with GoDaddy’s shared hosting. I’ll give a go to your tips befor moving to another hosting provider.
Thanks again
What a great article! Thanks for the useful information about optimizing WordPress blogs. My company runs two professionally, hosts a couple of personal blogs and will soon be hosting one for a client. Our new hosting provider provides a super fast connection but we know that things will slow down as our sites grow.
Peace,
David Peterson Harvey
Managing Director
thehiddenart.com
Hi,
I’ve installed super cache plugin. But my host recently suspended me because of 56% CPU usage. I’ve got my account back now and have removed some plugins now. But still CPU usage is around 45%. I get about 2k pageviews daily. Do I need to move to vps to handle the traffic? Or can a shared host handle this much traffic?
Thanks.
Mahesh.
Mahesh, how much traffic are you getting? A lot of traffic shouldn’t really cause much problems if you are properly optimizing your sites.
I would suggest removing all plugins(except your caching plugin) and maybe even switching to the twentyten theme for a couple of days. Watch your CPU and see if it does better. If it does, you’ll know that a specific plugin of yours has problems.
I also recommend the following plugin: http://wordpress.org/extend/plugins/wp-minify/
If you have more than one site, regardless of whether they are WordPress or not, they should be optimized too as they will contribute to the overall load.
If you still find you have problems, I can give more advice or you may just be getting large enough for VPS or you can see if your host provides a plan with more resources.
Hi,
Thanks for the reply. I’ve installed minify, disabled most of my plugins. I get about 2.5k pageviews.
My latest CPU usage is more than 35%. What do you suggest?
Thanks.
Mahesh.
Mahesh,
I get about 1.5K-2K page-views a day. Not quite as much as you, but still a considerable amount, and I have almost no CPU usage listed. I think that, based off of this information, that it seems your sites may just need more optimization.
Keep in mind that all of your sites contribute to your CPU problems. If you have any other sites, you should optimize those, too.
As was mentioned via my above CPU post, limit the number of posts you have showing at once. I keep the number of posts I have showing at once at 8, and my rss feeds at 5. Since your posts tend to be a bit larger than most of mine, you may want to limit it to 5 posts and 5 for rss feeds as well. Also set your rss feeds to only display a summary, and not the full post.
If that point was missed, or ignored, then I would guess that other points from my article were also missed or ignored. I would suggest you re-read it carefully and try the optimization steps again.
Here are some more links that can help you find problems on your site:
http://validator.w3.org/
http://www.websiteoptimization.com/services/analyze/
http://www.databasejournal.com/features/mysql/article.php/10897_1382791_1/Optimizing-MySQL-Queries-and-Indexes.htm
https://www.bluehost.com/cgi/help/000496
Hi,
I skipped the “number of posts part”. But now I’ve chosen only 5 posts to display now. Also, I’ve already repaired my SQL tables. Also, I upload images on Flickr, so images aren’t much of a problem.
Thank you my host offers only 10% cpu limit…. i will try to use ur tips thanks!
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….
Thanx a lot Michael.. This is really helpful to me. I’ve done some of your tips and my own blog become faster than before..
Thanx again..
I got same problem here about cpu usage on my blog…thks for this..i will try it..
tq a lot michael, i am wordpress new user,for me know this is big thing,
Thanks for this, been having real problems with my WP site slowing down. I’ve killed some old plugins and installed SuperCache and while its still not as fast as it should be its a lot better.
Perhaps I should consider changing hosts?!
currently on GoDaddy. :/
Add your Comment!