How To improve the performance of the wordpress blog?
Last day i was researching how to improve the website performance, then came across various articles on the web and did a lot of practice and research on the various suggestions, most of the impressive suggestions was by Elliott Back, some of the points mentioned below are explained crystal clear by him and a few more in context of the dedicated hosting, that i did not include here as i haven’t tested all the stuff..
WP – DBmanage
A nice Database plugin that will help in repairing and optimizing the Databases
WP Built-in Object Cache
Did you know WordPress will try and cache all kinds of database queries as files on disk? It’s so simple. Just add the following to your wp-config.php:
// Enable the WordPress Object Cache:
This can give a noticeable and immediate performance benefit. Less queries = less overhead and more CPU to go do other things. In case you don’t believe me, I just had a guy whose load average was between 20 and 50. After making this tiny change, it dropped to 2.
Wp-Cache or Super Cache are very important plugins, It serializes your posts to a file on disk and later spits them back. It’s the classic caching solution. It also knows how to update itself when comments are received, etc, so your site is always the most up to date.
Here is the complete list of plugins that run on this blog:
Content Filters: Adbright BritePic Enabler, Admin Info, Adsense Injection,Auto-hyperlink URLs, Feedburner Feed Replacement, Terms2tags, WordPress Duplicate Content Cure, WPvideo, WP Fixed Size, WP Adsense, WP-Stats, wp-cache
New Functions: delicious – Bookmark this!, Elliott’s Asides, Elliott’s Feed Tagger, Google Sitemaps, PJW Mime Config, Plugins Used, Relative Dates
Remote Services: Akismet, Extract Terms, Get RSS, Text Link Ads, WordPress From/Where
As you can see, there are just five that have any kind of processing impact. Akismet has to make calls to their web service to verify spam. Extract Terms uses the Yahoo API to build keywords for automatic tagging. Get RSS performs similar operations per post. Text Link Ads keeps track of an xml file it updates every now and then. WP From/Where archives the keywords used to find every post. The first four cache their results. WP From/Where is the only “expensive” plugin I have, since it adds a query to every page load.
You should go through your plugins, and see if there’s a way to make them faster. To make them stop creating queries and use flat files, or better yet, cache things. If your plugins are slowing down your WordPress installation, fix them and submit a patch their author. He’ll probably even give you a free link.
You can install something like xDebug to profile your PHP code for bottlenecks, as well.
MySQL Query Cache
The MySQL Query Cache saves results of queries in case the query comes by again. However, it only knows how to save the byte-text of queries, not their compiled versions, so small changes to the query will create different cache entries. Turn this on if you don’t have unique ids in every query. You can enable it by adding the following to /etc/my.cnf:
query_cache_type = 1
query_cache_size = 26214400
This will turn on the query cache and instruct it to use 26M of RAM. After you’ve changed the config, restart the MySQL process by /etc/init.d/mysqld restart and then run these SQL queries to verify that it’s working properly:
When I check, I find the Query Cache efficiency is at worst 10433610/21338215, or 49%. That’s not bad.
PHP is a beast with all kinds of horrible modules it thinks it needs to load. You find the php configuration usually at /etc/php.ini; here are some settings to observe:
;*Hide our info
expose_php = Off
register_globals = Off
register_long_arrays = Off
register_argc_argv = Off
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
;*Allow PHP to accept large data
post_max_size = 6M
file_uploads = On
upload_max_filesize = 6M
The real trick is to disable as many extensions as you aren’t using to save memory. You can check out this guide for more information about optimizing a php configuration.
Thanks to Elliot for the major contribution of what we managed hosted webmasters need in his website that has excellent resources: Elliott Back