Optimizing Your Drupal Site

Filed in by Chad Keck | February 2, 2010 11:12 am

Drupal[1] 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[2] 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[3] provides static page caching for Drupal, similar to how WP Super Cache[4] works for WordPress[5]. 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[6] & Cloud Servers[7] and even a few shared hosting platforms. Boost also includes partial support for Nginx, Lighthttpd and even IIS 7 (Apache[8] 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[9]
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[10] 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[11] platform. There are many options and one of the easiest and most cost effective to leverage is Cloud Files[12], which has built in CDN integration from Limelight Networks[13]. 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.

Endnotes:
  1. [Image]Drupal: http://drupal.org/
  2. this page: http://drupal.org/cron
  3. Boost: http://drupal.org/project/boost
  4. WP Super Cache: http://wordpress.org/extend/plugins/wp-super-cache/
  5. WordPress: http://wordpress.org/
  6. Rackspace Cloud Sites: http://www.rackspacecloud.com/cloud_hosting_products/sites
  7. Cloud Servers: http://www.rackspacecloud.com/cloud_hosting_products/servers
  8. Apache: http://apache.org/
  9. http://drupal.org/project/boost: http://drupal.org/project/boost
  10. DB Maintenance module: http://drupal.org/project/db_maintenance
  11. CDN: http://en.wikipedia.org/wiki/Content_Delivery_Network
  12. Cloud Files: http://www.rackspacecloud.com/cloud_hosting_products/files
  13. Limelight Networks: http://www.limelightnetworks.com/

Source URL: http://www.rackspace.com/blog/optimizing-your-drupal-site/