Skip to main content
17 Jun 2014

In CIGNEX, we review lot of modules to help our clients improve their website performance and scalability. We recommend few modules and configuration that has impact on Drupal website performance. Although hosting configuration helps them to speed up websites, aforementioned accelerators optimize Drupal websites:

  • APC - Alternative PHP Cache
  • PHP realpath_cache_size
  • MySQL Query Cache Size
  • Memcached
  • Drupal optimizations

APC

APC is one of the most widely used PHP opcode caching solutions in use today. APC should be installed and configured on every web servers. Two important benefits:

  • It will reduce the amount of RAM that actually server must use to render the page
  • It will reduce the time that actually server takes to render the page
     

APC has two default settings that will have a greatest impact on Drupal website.

  1. shm_size detemines how much memory it will allocate for single Drupal site.A good starting point for a single Drupal 7 site is 64MB although it should be monitor APC via the apc.php page to determine the optimal value for server and sites.
  2. stat determines if APC checks the original PHP source files ever modified before using the cached version. By setting stat=0, it will identified that php files do not change and thus reduce to check the status of PHP files.Disable stat on production servers where the source code rarely or never changes. Otherwise you'll find yourself having to manually clear the APC cache after every code update.

PHP realpath_cache_size

Most Drupal website makes use of include files. File pointers by default used by PHP to include files. Default cache size is 16k which is to small for Drupal websites. To increase this value change in php.ini for example: realpath_cache_size = 64KB. By injecting this php code :

<?php

  print_r(realpath_cache_size());

?>

on any page the actual usage of cache is display.

MySQL Query Cache Size

MySQL Query Cache Size used in memory cache for store the frequently executes select queries. Instead of executing query again MySQL retrieves the result directly from the cache and return Output. This variable is used globally for all MySQL clients. It is most useful for those websites that have frequent use of SELECT statement.

How to set variable:

mysql> SET GLOBAL query_cache_size = 1000000;

Query OK, 0 rows affected (0.04 sec)

mysql> SHOW VARIABLES LIKE 'query_cache_size';

+------------------+--------+

| Variable_name    | Value  |

+------------------+--------+

| query_cache_size | 999424 |

+------------------+--------+

1 row in set (0.00 sec)

Well in my case I have 4 GB RAM so i am using 32MB which is quite enough.

Memcached

"Drop-in" replacement library for caching that is used to mostly replace the cache_*tables in MySQL Database. Installing Memcahce and configuring in site to use it can have a dramatic impact on scalability and performance of Druapl Websites. Memcached shows that cache reads 2x faster and cache writes 4x faster and number of database queries was reduced by 50% per page load.

For using Memcached, there are three main components required:

  1. The memcached daemon itself (http://www.memcached.org)
  2. The PHP PECL memcached extension (http://pecl.php.net/package/memcached)
  3. The Drupal Memcache module (http://drupal.org/project/memcache)

Find more information for installation of Memcached from here: https://drupal.org/node/1131468

Drupal optimizations

Drupal works with some good performance optimization options if it configured properly. Here are few of them:

  • CacheRouter is allows user to assign individual cache table to specific cache technology
  • Enable Anonymous page caching
  • Enable CSS, JS, and Page Aggregation/Compression
  • Set a valid large expiration time, like 60-70 minutes for frequently caching content
  • Using the Boost module (http://drupal.org/project/boost) if your site has mostly anonymous traffic and you cannot setup a Varnish (https://www.varnish-cache.org/) server
  • Instead of using Statistics module, use external service as Google Analytics API

At a Glance

The conclusion is to improve performance of Drupal websites is all about enabling the server to render pages as quickly as possible while using few configuration settings available.

Above mentioned tools are core starting points for speed up your Drupal websites. Once these settings are configured to your working environment you will see significant improvement of high performance and scalability.