Static file caching - warmup

I need to get this info out in a nice concise fashion. Why? Because I was able to setup TYPO3 CMS that runs Documentation Planet so that static file cache is used for almost every page on the site. What is the immediate effect? Check it out for your self.

 

# ab -n 10000 -c 5 www.docplanet.org/linux/7-steps-to-convert-a-windows-user-to-linux/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, www.zeustech.net
Licensed to The Apache Software Foundation, www.apache.org

Benchmarking www.docplanet.org (be patient)
Completed 1000 requests
...[snip]...
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache
Server Hostname:        www.docplanet.org
Server Port:            80

Document Path:          /linux/7-steps-to-convert-a-windows-user-to-linux/
Document Length:        30616 bytes

Concurrency Level:      5
Time taken for tests:   19.830 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      309470944 bytes
HTML transferred:       306190616 bytes
Requests per second:    504.29 [#/sec] (mean)
Time per request:       9.915 [ms] (mean)
Time per request:       1.983 [ms] (mean, across all concurrent requests)
Transfer rate:          15240.51 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    3   3.0      2      76
Processing:     2    7   4.8      7     154
Waiting:        0    4   4.6      3     154
Total:          2   10   4.5      9     154

Percentage of the requests served within a certain time (ms)
  50%      9
  66%      9
  75%      9
  80%     10
  90%     10
  95%     10
  98%     16
  99%     25
 100%    154 (longest request)

Take note that the server on which Documentation Planet runs is not high end at all. It's a single core Pentium 4 at 2.6GHz with 80GB disk. This all works out, in my free estimate, to enough power to serve up to 30 page loads per second in a real life scenario which would give you enough juice to power a site with 1000000 visits per day. And all that on an industry strength CMS. Pretty impressive for that hardware. Unfortunately, for now, I am only visualizing that amount of traffic.

Now I believe that many of you noticed quite a number of CMS sites out there that just seem to load for ever. It's just too easy to make a bloated CMS site. I'll add this extension, and this one, and I must have a forum and all that fancy and nitty gritty. But that all adds up to increased bandwidth and processing time. Documentation Planet is a good example of a completely different approach. The less the better. No forum, no user logins, no unneeded extensions. Everything is compressed and minified as far as possible. You will notice the speed difference immediately if you are browsing in Chrome.

O.K. the goal looks juicy enough, but how to get there?

So the benefits are pretty obvious. And the question is how can you achieve this for your own sites? How does this work anyways?

Well... when boiled down, the principles of static file caching are actually pretty trivial. The idea is simply to save the result of PHP processing into a static file somewhere on the disk of the server and serve that on the next request instead of going through the usual grind of calling up PHP which in truns calls MySQL.

The thing is, there are some catches in the story. How do you know that PHP would not generate an output different from what is stored on the disk? It turns out that your CMS must have an inteligent enough design to be able to tell which pages can be cached because they are, at least, relatively static and which must never be cached.

Once this issue is sorted out you can start caching your relatively static pages.

Now, as you probably already know, my CMS of choice is TYPO3. In TYPO3, static file caching can be achieved using nc_staticfilecache. You can find instructions on how to setup nc_staticfilecache in the extension manual.  However there are a few tricks of the trade that you need to deploy to make nc_staticfilecache work as intended.

TODO: TS tricks

Your thoughts

No comments

Add comment

* - required field

*




*