5 Ways to Improve Drupal 7 Performance

When it comes to attracting and keeping site visitors, the research is clear - fast sites win out over slower ones. Users simply don’t have much patience with sites that take too long to load and that impatience isn't measured in seconds, but milliseconds. Here are five ways to speed things up on your Drupal site.

Drupal Cache

Using Drupal's built-in caching is probably the easiest way to improve performance on your site. However, some users that are new to Drupal miss out on this feature because it’s turned off by default. To enable caching for your site, go to the 'Performance' settings under the ‘Configuration’ tab.

After enabling caching, Drupal will begin storing database queries in a special table that allows for faster response times. One thing to note about caching is that Drupal is creating copies of the data in your database and these copies can get out of sync with the underlying data.

You can help manage this by setting the 'Minimum cache lifetime' and 'Expiration of cached pages' options. And of course, the 'Clear all caches' button will force Drupal to retrieve the latest data as it rebuilds the cache.

Also on the 'Performance' settings page are options to aggregate CSS and JavaScript files. This can help improve your website's speed as well, but having any of these settings active during development will cause a lot of headaches, so reserve them for use on your production site.

Boost

Another great way to improve your site’s performance is the Boost module. One of the big advantages to the Boost module is that it works well in shared hosting environments. A potential drawback is that if you’re not fairly experienced with Drupal, it can be a bit of work to set up.

Boost requires both Poormanscron (included in core with Drupal 7) and clean urls to be working. You’ll also need to have access to your .htaccess and robots.txt files to configure them for the module to work properly. That said, Boost is a great way to speed up your site that is even faster than Drupal’s built-in caching. It works by skipping the Drupal/PHP/SQL process and instead serves HTML or html.gz files.

An important point to note is that Boost only improves performance for anonymous users. If you have a large number of authenticated users, the next solution may work better for you.

Memcached

Another advanced solution for improving site performance is Memcached, but it’s not for everyone. First of all, it doesn't work in a shared hosting environment. A second potential issue is that you’ll need to be able to install and configure additional software on the server, so if you don't have permissions to do this on your host, you may need to seek assistance from a system administrator.

Memcached has three components, the Memcached software, a PHP extension and the Drupal Memcache module that work together to provide in-memory storage of database calls or rendered pages which makes it very fast. The documentation on how to implement Memcached provides a good explanation of how to get up it and running, but if you need further help, the Drupal community is a great place to look.

One interesting point is that a number of Drupal users are reporting success using Memcached and Boost together. If your website has a mix of anonymous and authenticated users, using the two together may be a great solution.

Varnish Cache

Varnish Cache is another solution that can supercharge the performance of your site. Like Memcached, Varnish has additional software to install. This caching HTTP reverse proxy system is quite technical, but if you want a lightning fast solution, it may be worth the investment.

In addition to the Varnish Cache software, you’ll need the Drupal module, Varnish HTTP Accelerator Integration. According to the module page, Varnish will serve pages at a much faster rate than Apache - close to 3,000 page views per second!

For Varnish to be useful on your site, you'll need either Drupal 7 or PressFlow. Check out the Varnish project page for details.

MongoDB

There are other ways of speeding up your site besides caching. MongoDB is a ‘NoSQL’ type of database that can be used for your Drupal site. Yes, this means there won't be a MySQL database on the back-end. This database system stores JSON documents instead of the records with which so many of us are familiar. This is how MongoDB avoids those resource hogging JOIN statements.

Another thing that really sets MongoDB apart is that the database is stored in memory, so writes are very fast. MongoDB does do occasional writes back to disk, but such traffic is greatly reduced. One criticism of keeping the database in memory is that some data would be lost in the event of a server crash. With the latest version, however, this issue can be solved with a simple configuration tweak.

NoSQL databases aren’t for everyone (at least not yet). But as proof they can work well for large production sites we can look to Craigslist, Disney and Foursquare among others. Oh, and to get MongoDB up and running, you'll need the Drupal module.

Wrapping It Up

Perhaps you’ve noticed a pattern here. Additional speed comes at a price. If you don’t own your own server or have dedicated system administrators, you’ll need to invest a bit of time and perhaps money to get a couple of these systems in place. At the very least, your site should have Drupal’s built-in caching system enabled and if you’re not seeing the gains you want from that, Boost is a relatively easy way to improve performance.

About the Author

John Hannah, Drupal theme designer

I’m John Hannah, a front-end developer, avid Drupalista and the guy behind Friendly Machine. I currently work for Woodward Design Group.

When I'm not building websites, I travel as much as possible and enjoy hanging out with my wonderful family. My favorite place to spend my coffee breaks is Twitter, so please feel free to connect with me there.

Comments