Archive - Web hosting RSS Feed

Quick and dirty WordPress speed comparison

This is just a quick benchmark of WordPress release 2.8.6, 2.9.2, 3.0.6, 3.1.4 and 3.2.

The test was done on a 512MB rackspace instance, running Ubuntu 10.10. With the following packages installed with default configuration: libapache2-mod-php5 mysql-server php5-mysql. Benchmark was done with ab, doing 10 000 requests to the front page, over 10 concurrent connections.

This is the result, in requests delivered per second:

Clearly, speed isn’t that much improved with the release of 3.2. However, this benchmark only tested the front page with the sample post.

WordPress 3.2 beta 1 speedtest

With every new WordPress release, things seems to be getting slower. But not anymore? With the release of WordPress 3.2 developers state that performance is getting better.

The test was done on a 512MB rackspace instance, running Ubuntu 10.10. With the following packages installed with default configuration: libapache2-mod-php5 mysql-server php5-mysql. Benchmark was done with ab, doing 10 000 requests to the front page, over 10 concurrent connections. Both blogs used the Twenty Ten 1.2 theme, and the supplied sample post.

This is the result, in requests delivered per second:

As you can see, things aren’t any faster, yet. But this is still a beta, and i only tested the performance of the front page, nothing else. I also tried the Twenty Eleven theme, but that wasn’t any faster.

Nginx, WordPress, WP Super Cache and Mobile Theme

I’ve previously written about how to configure WP Super Cache to work with Nginx.

When using a mobile theme plugin, WPtouch in my case, the serving of static files (WP Super Cache does that in rewrite mode) needs to be disabled for mobile requests. Otherwise you could end up with static files (containing your standard theme) being served to mobile users.

WP Super Cache also needs to be configured with Mobile device support to prevent mobile visitors from trigger static files to be generated. So start by enable that feature in the advanced settings for WP Super Cache.

Then change the Nginx rewrite rules to the following.

# Return existing files
if (-f $request_filename) {
        break;
}

set $supercache_file '';
set $supercache_uri $request_uri;

if ($request_method = POST) {
        set $supercache_uri '';
}

# Bypass cache for requests containing a query string
if ($query_string) {
        set $supercache_uri '';
}

if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
        set $supercache_uri '';
}

# Bypass cache for mobile users
if ($http_user_agent ~* "(Android|CUPCAKE|bada|blackberry 9800|blackberry9500|blackberry9520|blackberry9530|blackberry9550|dream|iPhone|iPod|incognito|s8000|webOS|webmate)") {
        set $supercache_uri '';
}

# Specify the cache file
if ($supercache_uri ~ ^(.+)$) {
        set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
}

# Serve the cache file, if it exists
if (-f $document_root$supercache_file) {
        rewrite ^(.*)$ $supercache_file break;
}

# Everything else goes to index.php
if (!-e $request_filename) {
        rewrite . /index.php last;
}

The user agents listed above are the same ones WPtouch sends the mobile theme to. If you change the settings in WPtouch, change the rewrite rules as well.

Reload Nginx.

Install, enable and configure the WPtouch plugin, and that should be it. I’ve been using this setup for about a month now without any problems, let me know if you run into something.

CloudFront with origin pull and WP Super Cache

Using AWS CloudFront as a CDN (content delivery network) for your site can be a good way of speeding things up.

CloudFront has support for origin pull (this way, there’s no need to sync files, they’re fetched on demand from the web server). Configuring this can be a bit tricky, since the AWS web interface only supports AWS S3 buckets to be configured as backends.

To get a distribution with origin pull up and running we need to do it manually. I’m assuming you’re working on some kind of unix/linux system (OS X for example). First of all, you need an AWS account with CloudFront. If you don’t already have one, get it here.

Create a file named .aws-secrets containing your AWS Access Keys (these can be found in the AWS Portal under Account -> Security Credentials), in the following format.

%awsSecretAccessKeys = (
    "my-aws-account" => {
        id => "ID goes here",
        key => "Key goes here",
    },
);

Create a XML file containing the settings of the new distribution, name it cf.xml.

<DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2010-11-01/">
<CustomOrigin>
    <DNSName>example.com</DNSName>
    <HTTPPort>80</HTTPPort>
    <OriginProtocolPolicy>http-only</OriginProtocolPolicy>
</CustomOrigin>
<CallerReference>1234</CallerReference>
<CNAME>cdn.example.com</CNAME>
<Comment/>
<Enabled>true</Enabled>
<DefaultRootObject>index.php</DefaultRootObject>
</DistributionConfig>

Replace example.com with your domain. CNAMES can also be added and changed later via the AWS Management Console.

Download the cfcurl.pl script.

Execute the following command.

cfcurl.pl --keyname my-aws-account -- -X POST -H "Content-Type: text/xml; charset=UTF-8" --upload-file cf.xml https://cloudfront.amazonaws.com/2010-11-01/distribution

Point the cdn domain you entered in the cf.xml file to the domain returned in the block with a CNAME. You can also get this name from the AWS Management Console.

If you don’t already have WP Super Cache installed, install it now. Then go to Settings -> WP Super Cache -> CDN and enter the cdn domain name as the Off-site URL and check Enable CDN Support.

Clean out the existing cache and visit your front page, content like css, javascript and images should now be loaded from the CDN.

Precaching with WP Super Cache

Since earlier this year, the WordPress cache plugin WP Super Cache supports precaching. This enables the ability to create static content of your entire site.

For a busy site this is probably not needed, since user activity triggers generation of static files. But for a smaller sites (like this one) it could help speed things up for both visitors and search engines, which in turn could improve your page rank.

I activated precache around midnight yesterday, this performance graph shows quite well the difference in loading times.

Page 1 of 212»