Experiment with WordPress Caching: Light Cache versus WP-Cache 2

By Angsuman Chakraborty, Gaea News Network
Tuesday, April 29, 2008

WP-Cache 2 and its younger cousin WP Super Cache have become de-facto suggestion for reducing site load for WordPress blogs. I used WP-Cache 2 on all my blogs. WP Super Cache despite its potential doesn’t improve upon the performance of WP-Cache 2 and brings in some problems.

Note: In the past we did extensive tests on WP Super Cache versus WP-Cache 2 and we couldn’t find any significant performance difference in either. In fact WP-Cache 2 performed slightly better in our tests. However this article isn’t about that comparison. In the past we have seen that even with wp-cache 2 / wp super cache, we suffered significant performance problems during peak hours. Neither of the plugins scale very well with high volume of simultaneous accesses despite any claims you may hear to the contrary. Try, for example, a simple ab (Apache Bench) test with 500 concurrent threads and you will find that with wp-cache 2 your whole site literally hangs for extended periods. You may even have to reboot your machine. We had to do it several times during our test. There are two ways around this problem.

If you have deep pockets like WordPress.com, you can throw more machines to the mix. We decided to innovate instead. Additionally we needed a better caching system for Translator Plugin Pro (WordPress plugin to translate your blog to 13+1 languages) & especially Translator Plugin Gold (WordPress plugin to translate your blog to 32 languages). Actually there is a bit of history here. Initially we used WordPress’ in-built object cache for translator plugins. Unfortunately object cache didn’t work too well for bloggers on shared hosting platforms. WordPress too realized the problems and removed file based object caching in 2.5. We acted before that and replaced it with database based object cache. It was a dramatic improvement but then database too has its limitations. We went through several rounds of optimization and finally we had a pretty good performance to be proud of. We didn’t stop there.

In our effort to find a better and simpler caching solution, both for WordPress blog and for Translator plugins we invented Light Cache. Today we deployed it on this blog. Tomorrow we will deploy it on all other blogs. What did we find out?

Performance, performance & performance
Couple of hours back I tested using ab (Apache Bench) a WordPress 2.5 blog (on Pentioum 4 1.8 Ghz). I tried first with 100 threads fetching a page and doing 10, 000 cumulative requests from another machine. I got a performance of 13.5 milliseconds per request. I did the similar test on the same blog using wp-cache 2 and got similar performance around 14.4 milliseconds. Nothing to write home about.

Next I tried testing Light Cache with 500 threads performing 10, 000 requests. It came back with 13.2 milliseconds average performance. I tried the same test with wp-cache 2 and it hanged the machine. I rebooted and tried with 250 threads and again WordPress and in turn the whole machine froze. As I mentioned before I faced such problems with wp-cache 2 in the past. In fact I face it almost every other day with heavy site load. I cannot explain it away with other factors like lower number of Apache threads etc. My site is tuned in every possible way, we also use eAccelerator.

I found out that Light Cache maintains its performance with 500 threads as will 100 concurrent threads. While this may be good enough for many, I wasn’t fully satisfied. The real test of a caching plugin is with real site load. So I did the unthinkable. I tested it on our live site, on this site. It was early morning in USA and the site load was heavy. I was having 30-34% idle cpu time on average. I decided to run 100 concurrent threads from another server using ab to fetch big page on this site (92K). I fully expected my site to hang. The Apache Bench finished quickly and gave me performance of 11.8 milliseconds. It was very surprising. Now I upped the ante and increased the thread count to 200. It came back with similar performance around 12 seconds. The CPU idle time fluctuated a bit but not by much and the sar generated average remained almost same. This was the defining moment. I knew I had a winner. Light Cache performed admirably in a live site with heavy load without breaking a sweat.

Light Cache comes with the basic functionality of wp-cache 2, setting cache time, showing stats, ability to clear cache etc. Light Cache is simple in design and does one job well, to serve lightning fast WordPress pages.

We may release it in near future as a separate product after some polishing and documentation. However it will also be bundled with Translator Plugin Pro & Translator Plugin Gold plugins.

Update: I just tested our live site with 300 concurrent threads with a 87K document. The average time per request is 9.5 milliseconds!

Document Length:        87247 bytes

Concurrency Level:      300
Time taken for tests:   94.616595 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      876999240 bytes
HTML transferred:       874640545 bytes
Requests per second:    105.69 [#/sec] (mean)
Time per request:       2838.498 [ms] (mean)
Time per request:       9.462 [ms] (mean, across all concurrent requests)
Transfer rate:          9051.73 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:      134  358 1050.0    209   21263
Processing:   832 2452 2146.6   1987   26659
Waiting:      149 1181 2231.5    585   25878
Total:        966 2811 2383.0   2201   26794

Percentage of the requests served within a certain time (ms)
  50%   2201
  66%   2376
  75%   2637
  80%   2802
  90%   3908
  95%   5658
  98%  10682
  99%  14725
 100%  26794 (longest request)
Discussion
November 9, 2008: 8:38 pm

We are extensively using it on several blogs. We couldn’t release it because of resource constraint.

November 9, 2008: 4:05 pm

I am very interested in your Light Cache plugin.
When will it be released?

May 6, 2008: 10:12 am

[...] A brand new caching engine with blazing performance. It will not only serve translated pages faster it will also make your [...]

April 30, 2008: 3:05 pm

Wohey, not bad at all! I look forward to hearing more Angsuman. Keep up the good work.

April 30, 2008: 10:18 am

Thanks. We are already beta testing it on this blog and few other blogs. Thanks for the offer. We will let you you if we need any external testing. So far we are extremely satisfied. I pounded the live site with 300 concurrent threads from a different server in Europe and it returned 90K pages at an average of 9.4 seconds!

April 29, 2008: 2:13 pm

I look forward to hearing more about this, both as a plugin, or as integrated into your translation plugins (happy customer here! :-)

I had the actual problem with WP-Cache 2, which I had to install after your Translator Pro plugin basically quadrupled the visits to my blog.

After running it for a while I found out it does not work that well, and made my site hang.

Let me know if you want a beta-tester?! :-)

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :