7 Drupal performance tips
17 May 2016

7 Drupal performance tips

Drupal is a universal open source CMS, which is successfully used to create sites of varying spheres, such as news portals, blogs, even online stores, due to the large number of additional modules. Depending on the Internet project orientation, the developers use the appropriate themes, modules and “ready-made” Drupal builds, created for the specific site types.

In this article, we’ll try to answer one of the most important questions the developers working with this platform are faced with: how to speed up Drupal.

Drupal speed up with the help of built-in tools

  1. The easiest way to start Drupal performance optimization is to use the existing internal tools. The most obvious step is to disable all the unused services (modules). Even if they are not used by the site’s code, they may still be running in the memory, burdening the server’s hardware. Even some of the needed modules you can still turn off, using the third-party services instead.
  2. Next is caching. The required functions are available at the “Admin – Settings – Performance” page:
  • Page caching for anonymous visitors can be turned on in the first section. The page is cached at the time of the first review and not generated from scratch the next time. If the majority of your website users are anonymous, this action will be extremely effective. To further increase the performance, the “Aggressive mode” can be activated. In aggressive mode, the CMS does not allow the loading and unloading of the activated modules. Although, the aggressive mode can lead to stability issues, so normal mode is recommended in most cases. Do not forget to set a specific time, after which the page must be generated again.
  • In addition, you can activate the page compression. Transmitting the page data in a compressed form will allow the page to load faster, which is good for the user, but increases the server load heavily.
  • Optimizing and merging the Javascript and CSS files can also reduce the page load time, as the data is transmitted in a single file. This option can be activated in a “Traffic optimization settings” section.
  • Enabling the block caching will also help to speed up Drupal site.

The additional activated modules allow to setup caching and compression in detail, but more on that below.

  1. We recommend disabling logging and statistics collection, as this will not only increase the speed of the site, especially under high traffic, but also helps saving the disk space. If you do not want to disable the statistics fully, it is possible to limit the amount of storage or timeframes. For example, at “Admin – Settings – Error reporting” page you can configure the error log storage settings.

Drupal performance tuning with the use of additional modules

  1. A useful module “Authenticated User Page Caching” helps you configure the page caching more efficiently than is possible with built-in tools. Authcache module can be downloaded from the official website. Next unpack the archive into “/sites/all/modules” folder. Copy the “ajax_authcache.php” file to the root folder of the site and add the following code to “settings.php” (the comments are for reading convenience, you can skip adding them):

$conf[‘cache_inc’] = ‘./sites/all/modules/authcache/api/authcache.inc’;

$conf[‘authcache’] = array(

 ‘default’ => array(

//caching technology – apc, memcache, db, file, eacc or xcache

‘engine’ => ‘db’,  

//if memcached is used (host:port, eg., ‘localhost:11211’)

‘server’ => array(),  

//if memcached shared single process is used

‘shared’ => TRUE,

//prefix key cache (for multiple sites)                 

‘prefix’ => ”,

//if file caching is enabled – saving path

‘path’ => ‘files/filecache’,

//static array cache (advanced)

‘static’ => FALSE,

 ),

);

Now, at the “Modules” page you can find the newly installed “Authcache”, start it and configure its settings.

  1. If the majority of sessions with your site are made by anonymous users, the “Cache Router” module would be more useful for you. It is downloaded, unpacked and hooked up similarly to “Authcache”, the code added to “settings.php” looks like this:

$conf[‘cache_inc’] = ‘./sites/all/modules/cacherouter/cacherouter.inc’;

$conf[‘cacherouter’] = array(

 ‘default’ => array(

‘engine’ => ‘db’,

‘server’ => array(),

‘shared’ => TRUE,

‘prefix’ => ”,

‘path’ => ‘sites/default/files/filecache’,

‘static’ => FALSE,

‘fast_cache’ => TRUE,

 ),

);

  1. Another useful module is the “DB Maintenance”. It helps defragmenting the MySQL database tables, data  of which are fragmented due to frequent updates. Loading such fragmented tables can reduce significantly the server performance.
  2. Employ the services of the content delivery networks, CDNsun, to name one

Optimizers and developers know that the geographical distance between the site’s hosting server and visitors directly affects its loading speed. In the event that users are viewing your website from various points in the world (as it often happens with large projects), the optimal solution would be to store the data on multiple servers that are located far from each other. It is made possible through the help of CDNs.

Among other things, reducing the distance between the server and the user have a positive impact to the site’s position in search engines’ rankings, and therefore, will help reaching a higher number of customers or readers.

The detailed content delivery networks explanation can be found in this article.