WP Super Cache Benchmarks

Today I will be covering an amazing plugin called WP Super Cache that aims to help speed up a WordPress blog. If you’re ever listed on the front page of Reddit or some other popular social media website you’re probably going to get flooded with visitors, which in turn will put a lot of pressure on your server to keep up with all of the requests. On every page view PHP will be executed along with a bunch of MySQL queries, this can put a lot of strain on your server if you happen to have a lot of active users. This is where WP Super Cache comes in.

WP Super Cache reduces this strain by storing a static HTML version of the pages the visitors view. This in turn reduces the amount of PHP executed thus reducing the strain. When a cached page changes, such as when someone comments or the post is altered, this HTML cache is simply updated.

I’ve also included benchmarks so you can compare the different options it has.

Lets get started!


WP Super Cache has two main modes:

Off Mode

When this option is enabled WP Super Cache is completely disabled, which is really only useful if you’re having problems with the plugin.

I’m benchmarking this site with the Apache HTTP server benchmarking tool from another VPS (both have 1000Mbps ports) in the same data center, running the benchmark from the same server could possibly give us inaccurate results. I’ve also left the number of requests low otherwise the benchmark would take too long to run. I probably should mention the command I’m using as well, so here you are:

ab -c 5 -n 1000 http://benscobie.com/

The Requests per second is what we’re mainly looking at:

Concurrency Level:      5
Time taken for tests:   62.744147 seconds
Complete requests:      1000
Failed requests:        87
(Connect: 0, Length: 87, Exceptions: 0)
Write errors:           0
Total transferred:      4959906 bytes
HTML transferred:       4674906 bytes
Requests per second:    15.94 [#/sec] (mean)
Time per request:       313.721 [ms] (mean)
Time per request:       62.744 [ms] (mean, across all concurrent requests)
Transfer rate:          77.19 [Kbytes/sec] received

 

On Mode

There are quite a few different options you can play with, however the main ones to mention are highlighted below:

  • Use mod_rewrite to serve cache files – This option requires no execution of PHP as cached files are served directly, this is the fastest method of serving them.
  • Use PHP to serve cache files – If for whatever reason you can’t use mod_rewrite then you should use this option. PHP is used to serve the cached files, it is almost as fast as the above option.
  • Compress pages so they’re served more quickly to visitors – Compresses the cached files with gzip so they can be served faster.
  • Don’t cache pages for known users – You should probably turn this on so pages and posts aren’t cached for you, so you can see what they look like etc.
  • Serve a supercache file to anonymous users while a new file is being generated – Instead of removing a cached page when it needs to be updated, a new one is created on the next visit and the old one is served until it’s created, otherwise people might hit a non-cached page resulting in increased load.

When I first ran this benchmark a few days prior to this post I didn’t get as good results as this, maybe I had compression turned off, but here we go (This was with WP Super Cache’s compression enabled):

Concurrency Level: 5
Time taken for tests: 4.835772 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 51870000 bytes
HTML transferred: 48180000 bytes
Requests per second: 2067.92 [#/sec] (mean)
Time per request: 2.418 [ms] (mean)
Time per request: 0.484 [ms] (mean, across all concurrent requests)
Transfer rate: 10474.85 [Kbytes/sec] received

That’s a staggering 7x more requests than the Half-on mode and nearly 130x more requests than with the plugin disabled. Now if your site got featured on the first page of Reddit your server should be able to cope with the amount of requests you’ll receive!

You could setup Nginx behind Apache to serve the HTML/compressed files and let Apache do everything else, you should be able to squeeze a few more requests with a setup like that.