Optimizing Your Drupal Site

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 every month that either want 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 quickly 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 solution. 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 highly 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'

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 optimizes 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 from the Rackspace Cloud, 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 leave a comment below, I’d love the feedback!

P.S. Looks like I’m going to miss DrupalCon this year for the first time in a few years, I’ll be enjoying my Honeymoon instead. Too bad they moved it to late April. I’ll look forward to 2011!

  • http://dankatz.net Dan

    Hi thanks for the tips.

    Can you elaborate on how to do CDN with Drupal. You say:

    “Uploading content to Cloud Files and enabling CDN distribution takes only a few seconds…”

    but then say

    “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….”

    Thanks in advance.

  • http://www.guntrustlawyer.net Blake

    Thank you for the article. This is some good information on how to lower your cpu cycle usage. From using Drupal on my site I have noticed that with the base install it barely uses any cpu. Although, once you start adding modules it jumps up quite a bit. Less cpu cycles used the better in my opinion.

  • Pingback: uberVU - social comments()

  • http://www.gloscon.com Roshan Shah

    We have been a proud Rackspace partner having managed some high traffic Drupal sites and have always been recommending Rackspace as the preferred Host for Drupal for those looking for Managed Hosting.

  • Tim

    I am in the process of developing a large, complicated Drupal site which has nearly 170 modules which has Devel Shutdown registering Memory Usage between 150 and 200MB. Obviously we are trying to limit modules to a minimum, but for the functionality we are trying to achieve it seems this is the number of modules we end up with and they add up quickly. Using Boost with our non logged on users have pretty fast pages, however we have very few users for the moment so do not know how such memory usage will be under load. Is Rackspacecloud Sites service an option that will alloy us to have such a site configuration and allow us to expand or handle traffic spikes without our users noticing? Will the servers give better performance for logged on users? Thanks

  • http://mc-kennna.com/ Damien McKenna

    Dallas Marlow commented on your blog post at rackspace.. it would be more useful to enable mod_deflate in Apache than to use compression in PHP.

    • http://www.chadkeck.com Chad

      I agree, but this is not an option that is open to everyone, it really depends on the hosting platform. For example, you would not be able to rely on this using the Cloud Sites platform at the Rackspace Cloud.

      I also know that this option may increase CPU usage, but it also cuts down page load time for optimization. I’ll make a note on the post with these details so people know its optional depending on their intention (page load times vs reduced resource utilization). Thanks for the comment though, I appreciate it!

  • Pingback: Tweets that mention Optimizing Your Drupal Site | Chad Keck DOT Com -- Topsy.com()

  • Pingback: Optimizing Your Drupal Site | Chad Keck DOT Com | www.kotihost.com()

  • scotjam

    There is a very powerful cdn module for drupal. I couldn’t notice it mentioned in the article, so I thought I’d suggest it.

    If links don’t work, just look for a project called ‘cdn’ in the drupal modules library. It also support CloudSites.

    http://drupal.org/project/cdn

    cheers
    scotjam

    • http://www.chadkeck.com Chad

      Thanks for the tip, I will check it out and test and then make another post here about it.

  • Pingback: I’m Reselling Rackspace Cloud Sites()

  • Pingback: Optimizing Your Drupal Site « Chad Keck | www.kotihost.com()

  • Pingback: Tweets that mention Optimizing Your Drupal Site « Chad Keck -- Topsy.com()

  • http://www.maxcdn.com Kevin

    Very nice article on optimizing your drupal site. Though as one comment suggests, there is a Drupal CDN plugin available that makes implementing a CDN (content delivery network) on your drupal site very quick and easy. MaxCDN is affordable and fully supports the drupal plugin with their Drupal CDN

    • chad

      Thanks Kevin for the comment and the note about MaxCDN. Looks like I need to update and re-publish the article. A lot has change since I originally published :)

%d bloggers like this: