|
Mar
16
2010
|
Post by James Jackson on Tuesday,
16th
March
2010
at 9:55 pm
Tagged: caching, cms, content management system, performance |
Over the weekend I ran a script to test the time it takes my server to process the home page of nojacko.com. I wasn't testing the time the page took to load but the time the server took to process it. I created a script that ran every 20 minutes, loaded the homepage's html, and grabbed he benchmarking information from the footer (which looks like "Page built in X.XXXX with Y queries & Z caches"). The script would first delete the site's cache and then load the site 10 times. This got the benchmark data for the site with caching as after the first load the site would have been cached. After this the script would again load the site another 10 times but before each load the cache would be deleted, getting the data for the site without cached data. I let this run for most of the weekend and here's my findings.
Something I have to point out is this site is hosted on a shared server (by HostGator who I highly recommend), so server side optimising is left to HostGator. Also other sites share the server so load that they create could have affected the results.
The first finding is easy to see. The site without caching takes 49% longer time to load on average. This is something I guessed would happen because with caching the site doesn't have to connect to the database and query it. The minimum and maximum loading times also show this. The maximum and minimum loading time for caching off was 41% and 75% longer, respectively, then when caching was on. 41-75% is a very noticeable difference. To put it into context if the site was maxing out 3 servers without caching turning caching on would in theory allow the site to run on only 2 servers.

The next thing I noticed was that when the database was being queried the difference between the average and maximum loading times was much higher than when cached. It seems that using a database the loading time is more variable. You can see from the scatter graph below that the cached times are more closely grouped between 0.01 and 0.1 seconds, whereas the non-cached times are more spread out between 0.02 and 0.5 seconds. Also, there were 11 instances of the non-cached site taking more than half a second and only 3 when the site is cached.

So the testing shows caching is worth while. In some cases your might not be able to cache or you might have a fast enough database server that the difference isn't noticeable but there is a good case for it. Increasing speed with caching can also save money and energy consumption as less servers are needed which cost both money and electricity.
I intend to do some more testing in the future. The next set of tests I do will probably be with part or full page caching, where I'll cache html outputs and not just the results of database queries.