Improving WordPress Performance

Posted: May 5th, 2010 | Author: | Filed under: posts | Tags: , , , , , | 3 Comments »

Hopefully, this blog is now loading a bit faster for you. As I think about how an individual’s web presence is increasingly a major part of their personal brand, it’s obvious that how that web presence operates must play into how the personal brand is perceived. Would you hire a web developer if their blog falls apart in your browser? Or a designer who’s site looks like it went through the Geocity-izer? Of course not. So, as a technology executive, I felt that a slow loading blog probably wasn’t good evidence of my abilities and invested a little bit of time to cut down some of the bottlenecks… (The last string of posts have been business-focused, too – it was time for another technical post.)

So, for other who may be running into similar issues, here are the steps I did to increase the performance of WordPress for my site:

 

Understand the Problem

First, you need to understand the issues that you’re facing. How severe is the load time and response time for your blog? How does it compare with other sites you’re running? I started tracking my blog with Pingdom to monitor the average response time. This demonstrated that there was a huge opportunity to cut the response time – it was twice that of other sites that I run.

Another good way to evaluate where your site stands is to use the Y-Slow plugin. This will give you many useful pointers and things to look into.

As for my analysis via Pingdom, you can see from the chart below, the first half shows extremely high average response times. After the changes, that has evened out and is much improved.

 

Memory Conflicts

The first step that I did was move WordPress to its own isolated username. For ease of administration in my shared environment (with DreamHost), I had been running a couple of sites under one username. As I started digging into the bottlenecks, DreamHost pointed out that processes were getting killed under that master username due to memory limitations. Having multiple sites trying to run processes at the same time under one user was a major reason for this. So, an easy fix was to separate the resource intensive sites to their own usernames. Your host may not allow multiple system users under one account, but if they do, take advantage of this easy way to balance out load and avoid running into imposed resource limits. This was an easy and obvious fix, but also one that wasn’t made in any of the WordPress performance guides that I read, so it may be useful to others.

 

The Database

The database is a common bottleneck. For most applications, the database is the chokepoint, especially as load increases. I’m running all of my databases at DreamHost on a “DreamHost Private Server” – this allows me a little more control with regard to the resources consumed by the databases and allows me to adjust resources based on usage. In taking a look at the resource usage, it was clear that resource usage was climbing and hitting limits here, as well. By checking the MySQL processlist, I could see a couple of poorly performing databases and queries from a couple of development databases we also run on the server. (yes, it’s best to keep your dev and production dbs separated and are in the process of moving the dev databases off of this combined server.) Killing these and restructuring some of the databases on the box was able to alleviate this issue quickly. Bottleneck mitigated – you can see the huge drop in memory usage in the chart below.

This is easy to check on your server. Just run the following command from the MySQL console:

show processlist;

Then, either take note of the queries that are running and figure out if there’s something else using the database that’s tying up the server’s resources or kill processes that are hung / locked. (Note if you have multiple usernames accessing the database, you may need to run the command from those multiple usernames to get an accurate picture. See the MySQL docs.)

 

Caching

Finally, if you’re looking to increase your WordPress install’s performance, make sure you have the WP Super Cache plugin installed. This was already installed on my blog, but it takes care of a number of common tasks, including caching and gzip compression.

So there are a couple of easy steps to help increase the performance of WordPress running on your server. Unfortunately, dealing with performance bottlenecks is a very case-by-case, application-by-application specific process, so these may not be immediately applicable to your situation, but perhaps they’ll provide some starting points and ideas.

 

Resources

Here are some other good references and posts on the subject: