How To improve the performance of the wordpress blog?

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:

1.// Enable the WordPress Object Cache:
2.define(ENABLE_CACHE, true);

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

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.

WordPress Plugins

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:

1.query_cache_type = 1
2.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:

01.SHOW STATUS LIKE 'Qcache%';
02.SHOW STATUS LIKE 'Questions%';
03.Qcache_free_blocks      2960
04.Qcache_free_memory  11693192
05.Qcache_hits     10433610
06.Qcache_inserts  5221850
07.Qcache_lowmem_prunes    2113131
08.Qcache_not_cached   1335038
09.Qcache_queries_in_cache     8765
10.Qcache_total_blocks     20976
11.Questions   21338215

When I check, I find the Query Cache efficiency is at worst 10433610/21338215, or 49%. That’s not bad.

PHP php.ini

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:

01.;*Hide our info
02.expose_php = Off
03.;*Turn off for performance
04.register_globals = Off
05.register_long_arrays = Off
06.register_argc_argv = Off
07.magic_quotes_gpc = Off
08.magic_quotes_runtime = Off
09.magic_quotes_sybase = Off
10.;*Allow PHP to accept large data
11.post_max_size = 6M
12.file_uploads = On
13.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

One Response

  1. Julo July 9, 2011