Thursday, September 02, 2010

Drupal 7 - faster than ever

This is a guest post by Owen Barton, partner and director of engineering at CivicActions. Owen has been working with Google's “Make the Web Faster” project team and the Drupal community to make improvements in Drupal 7 front-end performance. This is a condensed version of a more in-depth post over at the CivicActions blog.



Drupal is a popular free and open source publishing platform, powering high profile sites such as The White House, The New York Observer and Amnesty International. The Drupal community has long understood the importance of good front-end performance to successful web sites, being ahead of the game in many ways. This post highlights some of the improvements developed for the upcoming Drupal 7 release, several of which can save an additional second or more of page load times.



Drupal 7 has made its caching system more easily pluggable - to allow for easier memcache integration, for example. It has also enabled caching HTTP headers to be set so that logged out users can cache entire pages locally as well as improve compatibility with reverse proxies and content distribution networks (CDNs). There is also a patch waiting which reduces both the response size and the time taken to generate 404 responses for inlined page assets. Depending on the type of 404 (CSS have a larger effect than images, for example) the slower 404s were adding 0.5 to 1 second to the calling page load times.



Drupal currently has the ability to aggregate multiple CSS and JavaScript files by concatenating them into a smaller number of files to reduce the number of HTTP requests. There is a patch in the queue for Drupal 7 that could allow aggregation to be enabled by default, which is great because the large number of individual files can add anything from 0-1.5 seconds to page loads.



One issue that has become apparent with the Drupal 6 aggregation system is that users can end up downloading aggregate files that include a large amount of duplicate code. On one page the aggregate may contain files a, b and c, whilst on a second page the aggregate may contain files a, b and d - the “c” and “d” files being added conditionally on specific pages. This breaks the benefits of browser caching and slows down subsequent page loads. Benchmarking on core alone shows that avoiding duplicate aggregates can save over a second across 5 page loads. A patch has already been committed that means files need to be explicitly added to the aggregate, and fix Drupal core to add appropriate files to the aggregate unconditionally.



Drupal has supported gzip compression of HTML output for a long time, however for CSS and JavaScript, the files are delivered directly by the webserver, so Drupal has less control. There are webserver based compressors such as Apache’s mod_deflate, but these are not always available. A patch is in the queue that stores compressed versions of aggregated files on write and uses rewrite and header directives in .htaccess that allow these files to be served correctly. Benchmarks show that this patch can make initial page views 20-60% faster, saving anything from 0.3 to 3 seconds total.



The Drupal 7 release promises some real improvements from a front-end performance point of view. Other performance optimizations will no doubt continue to appear and be refined in contributed modules and themes, as well as in site building best practices and documentation. In Drupal 8 we will hopefully see further improvements in the CSS/JS file aggregation system, increased high-level caching effectiveness and hopefully more tools to help site builders reduce file sizes. If you have yet to try Drupal, download it now and give it a try and tell us in the comments if your site performance improves!



14 comments:

  1. twitter share doesn't work for me (chrome 6)

    ReplyDelete
  2. Yup, twitter share does not work. (Chrome 7.0.503 dev)

    ReplyDelete
  3. twitter on chrome 6 on an old XP, does not work for me....

    ReplyDelete
  4. @Balo, nsquare

    When you press it, a window with an X will appear on the right of the address bar. Click it, enable popups for this domain, and reload. Should work after that.

    ReplyDelete
  5. Twitter Share is NOT working on Chromium 7.0.510.0 (57926) via Mac OS X __ Not that I am trying to Twitter Share or anything... just trying it out to see if it doesn't work.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Great post. Love Drupal!

    ReplyDelete
  10. Integrating Drupal with a CDN will become trivial in Drupal 7 thanks to the CDN integration module!

    http://drupal.org/project/cdn

    ReplyDelete
  11. I just tried Drupal 7 last weekend, and found lots improvements :) It's really exciting :)

    ReplyDelete
  12. @Kyle2501 @Balo

    Hopefully some day folks will realize that this is *NOT* the place for bug reports or general fussing about Chrome. There is an entire forum, numerous discussion groups, and tons of help pages dedicated to those issues already. Posting comments about bugs here is A) extremely rude to the author and those of us trying to leave/read relevant comments and B) completely pointless, as they will likely never reach anyone working on the Chromium project who is capable of looking into them.

    ReplyDelete
  13. What I like in Drupal is that it has the ability that allows it to check for the latest release version and any installed modules and themes. You can also subscribe to the RSS feed of the security advisories page.

    ReplyDelete