Drupal coder

performance

An overview of Drupal's cache_clear_all uses

Drupal has a very simple, yet powerful (low level) caching system. It provides 3 functions that should please all you caching needs: cache_get, cache_set and cache_clear_all. The first two are pretty straight forward to use, but the third one might take some time to wrap your head around.

It accepts 3 argument: a cache ID, table cache and a wilcard boolean. Each combination of these 3 has a very different result. Here's an overview of all combinations.

May 19, 2010Drupal, performance

Performance tip : disable Drupal's core search indexer when using Apache Solr

Here's a quick tip for people using the (simply awesome) Apache Solr Search Integration module.

The Apache Solr module depends on Drupal's core Search module. This means the Search module will be enabled too when the Solr module is installed. As soon as the core Search module is enabled it starts to index all your nodes and stuff too. This not only takes time to run, but also fills up your database (search_dataset, search_index, ... tables).

Most of the time when you are installing the Apache Solr Search module, you don't need Drupal's core search form and replace the search form with the Apache Solr one using the Apache Solr module setting "Make Apache Solr Search the default:". You have now disabled the core Search module's form, but you have not disabled the indexing. To disable the indexing and save some CPU cycles and database space, just go to your site's search settings page (admin/settings/search) and set the "Number of items to index per cron run" to 0.

search-index-limit.png

Spread your cron schedule on machines running multiple Drupal sites

Here's a quick tip for people running multiple Drupal instances on one server: don't run cron for all sites on the same moment but try to spread it.

Suppose I have 5 sites: site1.tld, site2.tld, ... and I want to run cron each 12 hours. I would enter the following using crontab:

March 05, 2010cron, Drupal, performance

New Drupal book : Drupal 6 Performance Tips

Drupal 6 Performance TipsPackt Publishing is on a roll. They have been releasing a few Drupal books recently on a broad variety of topics. We have seen books on Social Networking with Drupal, JavaScript and jQuery, multimedia, ...

Last week they have released a new book focusing on performance and maintenance, called Drupal 6 Performance Tips. Although the title focusses on the performance topic, a lot of tips are also provided for maintaining or developing your site.

March 02, 2010books, Drupal, performance, reviews

How to create URL aliases in Drupal without path module

Creating pretty urls or permanent links in Drupal is easy. Really easy. This functionality comes out of the box with the Path module. And by adding the contributed Pathauto module you can make your life easier by letting Drupal generate the pretty urls automatically based on some properties of your post (like the title).

But there's another way of doing this in Drupal. Drupal provides a mechanism in code by means of the custom_url_rewrite_inbound and custom_url_rewrite_outbound functions. Using these wisely may give you some performance gain. Let's see how you can use these.

February 02, 2010Drupal, performance, url rewriting