WordPress performance with caching

In my last entry, I detailed the performance gains to be had from switching host providers.  That’s pretty cool, but a lot can still be done within WordPress to improve performance with caching.  Here, I’m going to use the URL from my previous blog post (https://ryanveach.com/280/i-switched-my-host-provider/), and I’m going to run it through similar benchmark tests to see what kind of difference that makes.

During these tests, nothing is being changed except for the caching plugin.  All server variables remained constant, and no other plugins were touched at this time.  This plugin will allow wordpress to generate a static html webpage to take the place of php/mysql code.  Therefore, a page request will simply read a flat file that is ready to go vs execute php code and pull data from the database, limiting processing time.

Note, this test is not downloading images, javascript or any other static content that can be included with a webpage.  I’m purposely leaving that out, testing the webserver’s ability to process the wordpress php code only.

Test #1: 1000 requests, single threaded

Example command: ab  -n 1000 -e post_280_ssl_std.csv -g post_280_ssl_std_gnuplot.tsv https://ryanveach.com/280/i-switched-my-host-provider/

General Numbers:

 Uncached  Cached
 Document Length  35424 bytes  35568 bytes
 Concurrency Level  1  1
 Time taken for tests  280.391 seconds  171.673 seconds
 Complete Requests  1000  1000
 Failed Requests  389 (length)  0
 Total Transferred  35,789,569 bytes  35,873,068 bytes
 HTML transferred:  35,423,569 bytes  35,568,000 bytes
 Requests per second:  3.57 [#/sec]  5.83 [#/sec]
 Mean time per request:  280.391 [ms]  171.673 [ms]
 Transfer rate:  124.65 [Kbytes/sec]  204.06 [Kbytes/sec]

For this test, there were 389 failed requests based on length.  Researching this error indicates it could be caused by dynamic content, and does not necessarily indicate a problem.  Therefore, I’m going to ignore this figure, and assume all connections were successful.

Mean Connection Times (ms):

 Uncached  Cached
 Connect  104  104
 Processing  176  67
 Waiting  133  35
 Total  280  172

The max times show pretty much the same story, so I’m going to skip those.

Timeseries Graphs:

Uncached Cached
post_280_ssl_std_gnuplot post_280_ssl_cache_gnuplot

System Resources:

There were no significant changes in free memory, disk utilization, etc on my server when running these two different tests, but I did see a significant difference in CPU:

 Uncached std_nmon
 Cached cache_nmon

Graphs are showing CPU data from nmon.

Test #1 Summary:

The data doesn’t lie.  Not only did the page load faster, but it used significantly less system resources.  While a normal user wouldn’t notice much of a difference in single page load times, this could make a huge difference if you are hosting a busy website with a lot of viewers.

So, let’s crank it up a bit:

Test #2: 10,000 Requests, 10 threads:

This test would more closely resemble that of a busy server, with multiple users hammering away.

Example Command: time ab  -n 10000  -c 10 -e post_280_ssl_std_10t.csv -g post_280_ssl_std_10t_gnuplot.tsv https://ryanveach.com/280/i-switched-my-host-provider/

General Numbers:

 Uncached  Cached
 Document Length:  35423 bytes  35568 bytes
 Concurrency Level:  10  10
 Time taken for tests:  1483.002 seconds  176.479 seconds
 Complete requests:  10000  10000
 Failed requests:  6441 (length)  6 (length)
 Total transferred:  357,895,589 bytes  358,730,538 bytes
 HTML transferred:  354,235,589 bytes  355,679,994 bytes
 Requests per second:  6.74 [#/sec]  56.66 [#/sec]
 Mean time per request:  1483.002 [ms]  176.479 [ms]
 Time per request (across all concurrent):  148.300 [ms]  17.648 [ms]
 Transfer rate:  235.68 [Kbytes/sec]  1985.06 [Kbytes/sec]

Mean Connection Times (ms):

Uncached Cached
 Connect:  109  108
 Processing:  1374  69
 Waiting:  941  36
 Total:  1483  176

Timeseries Graphs:

Uncached Cached
post_280_ssl_std_10t_gnuplot post_280_ssl_cache_10t_gnuplot

System Resources:

 Uncached: std_nmon_10t
 Cached: cache_nmon_10t

Test #2 Summary:

This test really helps detail the differences between a cached and uncached site using wordpress.

For the uncached site, the web server is definitely struggling.  Users are getting response times of about 1.5 seconds.  With this volume, in this current config, I would be upgrading the server, which would only cost more money.

For the cached site, it’s humming along.  Response times are slightly higher than they were in the single threaded test, but no human being would be able to tell the difference between 180 and 200 ms.  With CPU usage around 30-35%, I wouldn’t consider upgrading, but I would start keeping an eye on cpu trends weekly.

Closing Thoughts:

Caching plugins can certainly benefit your server’s performance with almost no negative side effect.  Not only can they speed up user’s response times, but they can also significantly reduce your server’s load, saving you money!

I theorized I was going to see some sort of performance gain, but I did not expect to see this large of a gain.

Leave a Reply