Home > General Articles > Speeding up WordPress home page

Speeding up WordPress home page

November 2nd, 2009 Leave a comment Go to comments

After about an year, since we launched Asianet News Portal the home page with all the complications had started to show a dead slow performance, and by using our Query Profiler, I could identify the bottleneck as the number of queries, and wordpress itself was telling the status as 48 queries in 6.344  seconds. Now this was a whopping value, and when the latency of 2 to 3 seconds is added to this, the initial html load would be in 9 seconds. Making the total site complete load in about 53 seconds. One can imagine the agony I was feeling, after all the work I had done to get backlinks, and if users who are visiting the site is just running away without waiting for the site to load, then I better not run the site atall.

I knew that all hope was not lost. Digging into the plugin documentations, identified some of the events which was fired after a post was saved, namely edit_post, and publish_post. Using this trigger, I created an updated cache of the homepage, just a serialized associative array of indexed hotareas, written to the ramdisk (/dev/shm). Changed the theme home.php to check there first, and if the file exists, the filemtime is the sites modification time, and the content is picked, unserialized and used to build the homepage. And the result is 7 queries in 0.195 seconds. Wow.. the page load is latency plus generation time means I saved about 7 seconds in the total time.
I was not contented with this. So modified such that the javascript libraries would be loaded from Google CDN. Removed the twitter counter images, and technorati direct link images. Instead just added a oneliner php twitter counter. Okay the total time for a fresh request is now about 40s and for a primed cache is about 4s which is far from what it was about a couple of weeks back. We are hoping to tie up with a CDN service soon.

  1. November 6th, 2009 at 22:46 | #1

    I feel your pain! But, the best move you can make with WordPress is to remove calls to the database and move to lighttpd for fastcgi on your php scripts – the speed increase is major on large bloated blogs. Oh, and throw plenty of RAM at your database – there’s only so many tiny improvements you can make!

  1. No trackbacks yet.

thirty two − twenty nine =