Ten Performance Commandments for Drupal

Drupal is slow. All of us know. But as they say humans have a tendency to aim for better and when we are better, aim for excellence. So out of human tendency while searching for improving the scope of performance, I came across few points which needs to be taken care of while developing a new Drupal site.

Ten commandments

  1. Enable caching and aggregation for css and js. Include css in head and js in bottom of template file.

  2. Never write heavy code in tpl files. Template files are only for rendering html, not for heavy DB queries and complex php code.

  3. Don’t use php filter in custom block. Use hook_block () for custom blocks.

  4. Minimize HTTP Requests. This has great impact on performance. Use image sprite OR data-uri’s for images.

  5. Some useful module are performance killer like admin_menu, devel, context_ui, views_ui. So uninstall them on production site.

  6. Use long expire header in htaccess. eg.

ExpiresByType text/javascript "access plus 2 month"
ExpiresByType text/css "access plus 2 month"
ExpiresByType image/gif "access plus 2 years"
ExpiresByType image/jpeg "access plus 2 years"
ExpiresDefault A2592000
  1. Some of these tools could be useful. Varnish, APC, mysql-tunner.

  2. Maria db is way faster than mysql. Drupal.org is using this.

  3. And If you have extra money, you can use CDN (Content Delivery Network).

  4. If you are dealing with huge drupal site, you must take a look at this video