Friday, October 10, 2008

Performance improvement guidelines for drupal sites

In most of the web pages, less than 20% of the total response time is used to retrieve the HTMl document. That means the other 80+% is used to process what's in the HTML file: CSS, JS, images, videos. And in many cases, that number is even higher.

In order to improve the performance on drupal sites, drive in to the following procedures. This includes both the server side caching and YSlow for Firebug recommendations.

Drupal Side

Ø Enable the CSS Aggregation and JS Aggregation from the drupal administrators settings (In drupal5 JS Aggregator is a separate module - http://drupal.org/project/javascript_aggregator).

o If js errors are encountered, disable the option ‘optimize js files’ from your drupal settings or make sure all the comments in the JS files are valid.

o After enabling the ‘CSS Aggregator’, if the theme gets messed up make sure that the CSS files are commented properly.

Ø Activate the memcache (http://www.danga.com/memcached/) by installing this service. Memcache is intended for use in speeding up dynamic web applications by alleviating database load.

o Install the drupal-memcache module in drupal5 as a module (http://drupal.org/project/memcache).

o After installing this module, add the following lines in settings.php

§ $conf = array(
'cache_inc' => './sites/all/modules/memcache/memcache.inc',
// or
// 'cache_inc' => './sites/all/modules/memcache/memcache.db.inc',
);

o This will override the default cache file (ie) cache_set() and cache_get() functional calls will get data from the memcache server and not in the drupal cache table. So number of db calls and query time will be reduced.

Ø If the information is retrieved from views, avoid the usage of calling views_view() for many times and store the output of the views in cache by using cache_set(). Clear the cache periodically based on the view type and avoids showing the static information.

Ø Enable the ‘page caching’ from drupal settings so that anonymous users will be benefited and re-construction of web page will be avoided.

Apache Side

Ø Add an expires headers for all the files types like CSS, Images etc.

o Changing the future date for the Expires headers is easy enough: simply edit your .htaccess file. Your Apache server must also have mod_expires installed; this is available by default on most servers.

Ø Add the gzip component so that web pages are written to the cache in GZIPped form.

o Following lines has to be written in .htaccess file for gzip

§ “AddOutputFilterByType DEFLATE text/css application/x-javascript”.

Ø An ETag uniquely identifies a file, and is used to verify if the file in the browser's cache matches the file on the server..

o Following lines has to be written in .htaccess file for disable etag

§ “FileEtag none”.

References :
1. http://wimleers.com/article/improving-drupals-page-loading-performance
2. http://video.yahoo.com/watch/1040890/3880720





No comments: