I’ve just discovered that WordPress and a couple of other sites I run casually tax my CPU really highly running the PHP scripts (the database is on a separate server). I know WP can cache, so I decided to play around. The result? WP Super-Cache results in a (more than) 10x speed improvement just using the “half cache”. What it’s doing is writing the database queries to disk, so it doesn’t have to figure out the result of the query every time it processes the page.

Here are the actual results.

I’ve just discovered that WordPress and a couple of other sites I run casually tax my CPU really highly running the PHP scripts (the database is on a separate server). I know WP can cache, so I decided to play around. The result? http://ocaoimh.ie/wp-super-cache/ results in a 10x speed improvement just using the “half cache”. What it’s doing is writing the database queries to disk, so it doesn’t have to figure out the result of the query every time it processes the page.

By the way, the CPU is a K6-2 333MHz. I imagine the gain would be smaller on a faster CPU, as a faster CPU processes non-cached results faster => smaller difference between cached / non-cached results => smaller gain.

Here are the actual results.

Results with no cache:

#ab -n 30 "http://www.sirspanky.com/wp/"This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking www.sirspanky.com (be patient).....done

Server Software:        Apache/2.2.3
Server Hostname:        www.sirspanky.com
Server Port:            80

Document Path:          /wp/
Document Length:        56172 bytes

Concurrency Level:      1
Time taken for tests:   170.354564 seconds
Complete requests:      30
Failed requests:        0
Write errors:           0
Total transferred:      1692660 bytes
HTML transferred:       1685160 bytes
Requests per second:    0.18 [#/sec] (mean)
Time per request:       5678.486 [ms] (mean)
Time per request:       5678.486 [ms] (mean, across all concurrent requests)
Transfer rate:          9.70 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    1   0.2      1       2
Processing:  5465 5676 349.0   5578    7057
Waiting:     3255 3422 236.1   3378    4581
Total:       5466 5677 349.1   5579    7058

Percentage of the requests served within a certain time (ms)
  50%   5579
  66%   5602
  75%   5610
  80%   5635
  90%   6010
  95%   6747
  98%   7058
  99%   7058
 100%   7058 (longest request)

Results with half cache:

#ab -n 30 "http://www.sirspanky.com/wp/"
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking www.sirspanky.com (be patient).....done

Server Software:        Apache/2.2.3
Server Hostname:        www.sirspanky.com
Server Port:            80

Document Path:          /wp/
Document Length:        56226 bytes

Concurrency Level:      1
Time taken for tests:   8.188850 seconds
Complete requests:      30
Failed requests:        29
(Connect: 0, Length: 29, Exceptions: 0)
Write errors:           0
Total transferred:      1695860 bytes
HTML transferred:       1687940 bytes
Requests per second:    3.66 [#/sec] (mean)
Time per request:       272.962 [ms] (mean)
Time per request:       272.962 [ms] (mean, across all concurrent requests)
Transfer rate:          202.23 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        1    1   0.2      1       2
Processing:    55  271 1122.7     61    6215
Waiting:       39  254 1116.1     45    6163
Total:         56  272 1122.9     62    6217

Percentage of the requests served within a certain time (ms)
50%     62
66%     63
75%     64
80%     69
90%    126
95%    133
98%   6217
99%   6217
100%   6217 (longest request)

As you can see, only 1 request (3%) took 6217ms to load with the cache, then the rest load in <200ms. Without the cache, half of the queries take longer than 5579ms and the other half…well they probably take 5578ms ;)

Written on October 4th, 2008 , Informative

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

SirSpanky.com – The Secret Diary of James Pearce Aged 20-Something is proudly powered by WordPress and the Theme Adventure by Eric Schwarz
Entries (RSS) and Comments (RSS).

SirSpanky.com – The Secret Diary of James Pearce Aged 20-Something

Personal jorunal of a professional geek – James Pearce in Perth, Australia