Summary: This post provides a review of the Drupal Boost module, which dramatically improves website speed/performance.
Over the last few weeks I've been spending a little time every weekend trying to improve the performance of the alvinalexander.com website. I didn't think there was much of a performance problem with the website, but the Google Webmasters' site kept reporting that the site was slow compared to most internet websites.
As I dug further into their numbers I saw that although the website is generally very fast, it does bog down when it really gets hammered. Most pages are rendered in less than a second, but when it gets hammered it can take much longer to respond to page requests, and the problem gets worse and worse until the server load lightens.
PHP APC Opcode Cache and Amazon CloudFront
Because this blog runs on Drupal, and Drupal runs on PHP, the first thing I did was to install and configure the PHP APC Opcode Cache. APC essentially compiles your PHP source code into binary code, so your PHP files/scripts don't have to be interpreted on every web page request.
I used the Apache ab benchmarking tool to measure the performance before and after adding APC, and found that the APC cache reduced the time it took to serve 1,000 Drupal page-views from 14.8 seconds to 4.2 seconds. I documented that in my Drupal PHP APC performance improvements article, and I thought that was a big win.
This weekend I planned to install the Drupal Boost module, followed by installing the Varnish Cache next weekend.
Drupal Boost module performance
This morning I installed the Drupal Boost module, and once I finished configuring it and letting its cache build, I ran the same Apache ab benchmark performance tests. To say the least, the performance improvements are outstanding:
|Without APC||With APC||Drupal Boost|
|Time taken for tests:||14.8 secs||4.2 secs||0.5 secs|
|Requests per second:||67.4||236.6||1875.5|
|Time per request:||74.1 ms||21.1 ms||2.7|
As you can see, two weeks ago it took 14.8 seconds to render 1,000 Drupal page views, and after adding the Drupal Boost module this morning, the website now renders the same number of pages in only 0.53 seconds! I believe it's correct to say that web pages are now being served in only 3.6% of the time it took two weeks ago.
(Statisticians can help me here: Is it accurate to say that a reduction in time from 14.8 seconds to 0.53 seconds is a 27.9x improvement?)
Why Drupal performance matters
If you own a website, you know that the page-views served to actual human readers is a small subset of your overall website traffic. In addition to real people reading a website, you also have all sorts of bots and crawlers hitting the site, as well as spammers trying to hit your contact and comment forms. For me, that traffic load is pretty much 10x the page-views from humans.
Because alvinalexander.com serves millions of page views to humans every year, and because this website contains over 100,000 pages of tutorials and source code examples, you can imagine that with all these requests the hard drives here are always trying to respond to requests. Therefore, a performance improvement from 67 requests per second to 1,875 requests per second can really help lighten the overall server load.
I'm sorry I didn't think to measure these numbers before starting the optimizations. The only thing I was worried about when I started this process was making the website faster, but now I see the other side of this is greatly reducing the overall server load, which helps me handle much larger traffic spikes.
How the Drupal Boost module works
There are some really nice documents on the Drupal website about how the Drupal Boost module works, but in short the module:
- Turns your Drupal web page content into static files.
- Uses Apache rewrite rules to serve the static files to anonymous website visitors.
- Serves compressed versions of those files when it can.