Support: 1-800-961-4454
1-800-961-2888

Optimizing Your Drupal Site

13

Drupal is a widely used open-source CMS platform that is becoming increasingly popular by the day. I have personally used Drupal on/off since v4 and have seen it mature over the years into my preferred content management system. Here at the Rackspace Cloud we speak to hundreds if not thousands of new customers and prospects that are either wanting to migrate their existing Drupal sites into the Cloud or start fresh with Drupal.

Improving performance is always a concern with any site and after working with countless Drupal installs I have identified a few tools and options that can very easily make a very noticeable difference in your sites performance. These tweaks are not specific to the Rackspace Cloud platforms and should be considered by any Drupal site admin on any hosting platform. They will not only improve the performance of your site but also reduce back-end resource utilization such as CPU and memory or lower compute cycles on Cloud Sites for example. This is achieved through various levels of static page caching and a more optimized database. Let’s take a look at the options.

Before we look at any third party modules lets examine what Drupal has built-in that can help. Navigate to Administer –> Site Configuration –> Performance. This section allows users to enable/disable specific caching functions included in Drupal CORE. Here are my recommendations for a typical Drupal site:

¥    Caching Mode: Normal
¥    Page Compression: Enabled
¥    Block Cache: Enabled
¥    Optimize CSS Files: Enabled (use in production only, not during theme development or customization)
¥    Optimize JavaScript Files: Enabled (use in production only, not during theme development or customization)

Next I highly recommend setting up a cron job to run the Drupal cron.php file regularly, I typically run it once per day but it depends on your site (heavy traffic sites might want to run it more often). While this may not have a direct performance impact it is good general practice as executing this script performs many maintenance tasks including cleaning up old log files and checking for updates. Setting up a cron job is pretty simple and some hosting platforms such as Cloud Sites can make this a point/click configuration. Reference this page for more information on how Drupal uses cron and setup instructions.

Now, lets take a look at two third party modules that I have used for sometime that can have a dramatic impact on your site:

Boost

Boost provides static page caching for Drupal, similar to how WP Super Cache works for WordPress. This module works extremely well if your site received mostly anonymous traffic. The developers make this module a breeze to set up and configure and I’ve tested it across many platforms including a dedicated Linux server, Rackspace Cloud Sites & Cloud Servers and even a few shared hosting platforms. Boost also includes partial support for Nginx, Lighthttpd and even IIS 7 (Apache is fully supported). Let’s walk-through the set up:

*Note, Boost requires cron and clean-URLs to be enabled FIRST*

1.    Download Boost here: http://drupal.org/project/boost
2.    Extract and upload to your Drupal /modules folder
3.    Navigate to Administer –> Site Building –> Modules
4.    Enable Boost
5.    Navigate to Administer –> Site Configuration –> Performance
6.    Notice the new options for ‘Boost’ on the top navigation menu, click Boost Settings
7.    Review and adjust any settings necessary (I generally stick to the defaults)
8.    Click ‘Boost htaccess rules generation’ in the top nav menu
9.    Copy the automatically generated htaccess rules and paste them in your htaccess file, see below:

# RewriteBase /
<<INSERT BOOST CODE HERE>>
#Rewrite URLs of the form ‘x’ to the form ‘index.php?q=x’

10.  Modify this line:

%{DOCUMENT_ROOT}/cache/

to

/mnt/path-to-my-site/web/content/cache/

Boost should now be up and running. Be sure to check your Administer –> Reports –> Status Report page for any errors.

DB Maintenance

The DB Maintenance module optimized administrator selected tables in your Drupal sites database during the regular cron.php executions. Keeping your database optimized is one of the easiest ways to ensure a smoothly operating site on any platform and is essential if you want to scale your site effectively for high traffic. Installation is fairly quick and easy:

1.    Download DB Maintenance here: http://drupal.org/node/41588
2.    Extract and upload to your Drupal /modules folder
3.    Navigate to Administer –> Site Building –> Modules
4.    Enable DB Maintenance
5.    Navigate to Administer –> Site Configuration –> DB Maintenance
6.    Select tables in the Drupal database that you wish to optimize during the regular cron execution and enable logging if you prefer
7.    Save and thats it!

It is suggested to keep your selections to tables where there is a lot of data movement such as accesslog, cache, sessions, and watchdog. You can always make a separate and more infrequent cron as part of your regular server management if you want/need to optimize your node tables.

CDN Integration

The final tip I’ll leave you with is one of the most important and that is serving your static content from a CDN platform. There are many options and one of the easiest and most cost effective to leverage is Cloud Files, which has built in CDN integration from Limelight Networks. Off-loading your static content such as images, video, audio, documents, etc to a global content distribution network not only decreases even more load on your hosting platform but it makes site load times significantly faster by serving this content as close as geographically possible to your site visitors (local or close to local data centers).

Uploading content to Cloud Files and enabling CDN distribution takes only a few seconds and is the preferred method for embedding static content, especially large video and audio files. Currently there are a few Drupal modules in development that support Cloud Files and other storage/CDN platforms on varying degrees but none that I’m comfortable mentioning just yet. Once these mature it will only make using these platforms even easier.

Deploying these tips and modules should have a significant impact on your sites performance. There are countless other ways to further optimize your site in addition to this so don’t hesitate to explore other options as well. I hope this is helpful to new Drupal users and even seasoned noders alike.

If you found this article helpful or have anything to add please don’t hesitate to leave a comment below.

About the Author

This is a post written and contributed by Chad Keck.


More
  • http://wonderingfish.com Wayne

    Thanks for this article, it is really nice to see support for Drupal (and not just WordPress!). I look forward to more Drupal related posts.

  • http://www.chadkeck.com Chad Keck

    Glad you enjoyed the post. I’d love to do more write-ups on Drupal, so if there is anything specific you would like us to cover throw it out there and I’ll dig into it. Thanks!

  • lars

    On the server side, I’ve found APC and memcache along with the recommendations above to quite beneficial with Drupal.

    They are easy to set up on a CloudServer in particular.    

  • Dallas Marlow

    Page Compression: Enabled

    this is a horrible suggestion, especially if your goal is to lower cpu and memory consumption. configuring mod_deflate to gzip your css, js and html output is far better in terms of both
    performance (page generation times) and server stress (cpu and memory usage).

    as lars mentioned as well, op_code caching (apc, eaccelerator, etc) is a big help too (especially under a load).

  • Matt

    We also recently added Rackspace CloudFiles support to Storage_API module, and sort of CDN module that integrates with the excellent bd_video module.

    http://drupal.org/project/storage_api

  • Pingback: Elsewhere, on February 8th - Once a nomad, always a nomad

  • zdean

    regarding “Currently there are a few Drupal modules in development that support Cloud Files and other storage/CDN platforms on varying degrees but none that I’m comfortable mentioning just yet. ”

    anything new on this front?

  • Pingback: Drupal Speed Optimization and Performance Articles | Concise Developer

  • http://capalon.com nstampler

    Re “regarding “Currently there are a few Drupal modules in development that support Cloud Files and other storage/CDN platforms on varying degrees but none that I’m comfortable mentioning just yet. ” –

    I’d like to set up CDN for the many product images on my Drupal-Ubercart site. It’s been a few years since this original post. Can you now recommend a Drupal module to support CDN?

    Thanks.

    • http://capalon.com nstampler

      Actually, I see http://drupal.org/project/storage_api referenced in the comments. I’ll start with that, but please do comment if you have any other recommendations.

      Thanks.

  • Joe

    3 drupal modules currently claim to support Rackspace Cloudfiles for CDN purposes:
    - Cloud Files
    - CDN
    - Storage API

    It’s been almost 3 years since any updates here by the op. Let’s see a tutorial for this configuration in Drupal 7 that actually works! Thanks!

  • Vladimir

    Good thoughts and no measurements. What speed do you have on fresh drupal site without any 3d party modules? I mean on rackspace hosting? On my local mashine i see 250ms for gerland page, on rackspace same page renders very bad. Before any optimization there must be some ground from which to push off. So what basic speed do you have?

  • narendra

    nice article

Racker Powered
©2014 Rackspace, US Inc.