2009-09-29 13:57:47

Optimizing Drupal 6, Gain Performance and Stability!

drupal man says owwhhh yea!In general, Drupal will be sufficiently stable and performant enough to run your average website.  But when you are rebuilding your website or a website of your customer that gets tons of pageviews, you'll start to encounter slowdowns, downtime & unexpected behaviour. Read more for Drupal 6 optimizing tips & tricks. Do note that I won't be covering standard Drupal cache, I expect you to have this enabled already.

Tip #1 Caching expansion

There are several good caching modules out there. Some are unstable or neglected by the Drupal community, others are just not worth the hassle installing. Personally I prefer using Advanced Cache module. The advanced caching module is mostly a set of patches and a supporting module to bring caching to Drupal core in places where it is needed yet currently unavailable. These include caching nodes, comments, taxonomy (terms, trees, vocabularies and terms-per-node), path aliases, and search results.

This module will give you your first performance boost, even if you're using standard Drupal cache to support it. There are also two (minor?) downsides when using this module. First one being that you have to hack Drupal core and second one is that it hasn't received a lot of feedback for Drupal 6.

Also download the patches I have contributed to ensure *everything* is being cached correctly and that the patches work on the latest Drupal release.

Tip #2 Memcache

Memcache is probably the easiest performance improvement you can get. No patching required, you just need to set up a memcached daemon and you'll be on your way.

You will want to split your caches up into several bins. This will reduce the impact of a cache rebuild on your server. You can find all the information on how to set up and install this module on it's project page.

Tip #3 Proxy caching

Using a proxy to cache your static files is a good idea. And caching dynamic pages too is an even better idea! But... aiii... again, this involves hacking Drupal core.
You can choose between varnish, squid or apache's mod_cache. They all work the same and none of them has proven me to be a "better option".

Tip #4 Alternative search solution

The Drupal search will cause a very nasty load on your database server if you get a few requests at the same time. But don't panick, there are several options available to lighten the load.

Currently, apache SOLR is considered the Drupal way to go if you're looking into an alternative search solution. Admitted, this module does get more support and has more options than any other. On the other hand, it will put strain on your web an database server while doing indexing & re-indexing. The maintainers of the Apache SOLR module are looking into ways to improve this.

Anyway, untill they have fixed the module, I'd suggest using the Sphinxsearch module. It has fewer options, but Sphinx is able to index your website without using the Drupal API or PHP.

Tip #5 Minimize the use of the views module

The views module must be one of the greatest things since sliced bread. It allows you to easily set up new aggregations of nodes, users, ...
Too bad we can't say the same about it's performance. When you use this module, you have to know that you're on thin ice. A wrong decision in your admin cp can easily cause a slow query to be generated and that'll affect your whole site.
My advice here is to hard code as many views as possible. It'll take a bit longer, but it'll save you pain in the long run.