Quantcast
Channel: IT-Linux
Viewing all articles
Browse latest Browse all 171

How To Improve Drupal Performance On Your Localhost

$
0
0

In this post Im going to discuss about improving Drupal performance on your localhost – PAE, APC and MySQL tuning. My old laptop had broken down, and I had to quickly find a cheap substitute, which had a bit different configuration: two AMD cores VS four Intell i3 cores and 4GB vs 3GB. So, I decided to try Linux Mint, which is said to be better than Ubuntu. IMO for LAMP stack the name of the Linux distribution is not so important, because they are all working good, however you should decide which version to chose: 32 bit or 64 bit. I found out that 64 bit Linux is better for development, but it could be not good enough for some applications.

Memory utilization for 32 bit Linux

So, I decided to choose 32 bit version of Mint. The problem was that the first thing I noticed was that 2.6GB of RAM was only available. That seemed absurd and was definitely one of disadvantage of 32 bit system. When I was running full LAMP stack + IDE + Skype I saw almost all memory was used and some disk space was taken for swap. Luckily enough Physical Address Extension (PAE) was there to help, which could be installed with the following command:

$ sudo apt-get install linux-generic-pae linux-headers-generic-pae
This worked pretty well and system monitor showed 3.5 GB of RAM. Not 4 still, though it could be a unit conversion issue. However, I was happy that the system was working faster now.

Configuring Alternative PHP Cache

I had cloned a big project and saw how my machine was trying hard to handle requests, which slowed down the system. The way out was installing APC. Alternative PHP cache is open source and free framework that optimizes PHP intermediate code and caches data from PHP compiler in shared memory. In Mint or Ubuntu, it could be installed with the following command:

$ sudo apt-get install php-apc
I ensured that /etc/php5/conf.d/apc.ini file was in place and over-rode the default settings:

Extension=apc.so
Apc.shm size=128M
Apc.max file size=10M
I installed APC module that allows storing Drupal cache in memory instead of database. I ensured that the cache tables size was less than shm_size in config file. Then I enabled the APC module and added the following into settings.php file:

$conf[cache_backends] = array(Sites/all/modules/apc/drupal apc cache.inc);
$conf[cache_backends] = DrupalAPCCache;
$conf[page_cache_without_database] = TRUE;
$conf[page_cache_invoke_hooks] = False;
MySQL tuning

Instead of enabling APC cache, database performance was not getting affected. So, I changed the settings of MtSQL to make it work faster. The following are the values with which I overrode MySQL config. Files:

/etc/mysql/mysql.cnf:
[mysqld]
Key buffer = 128M
Max allowed packet =128M
Max connections =300
Table cache = 256
Query cache limit = 16M
Query cache size = 128M
/etc/mysql/conf.d/innodb.cnf:
[mysqld]
Innodb buffer pool size =1024M
Innodb additional mem pool size =32M
#innodb log file size = 16M
Innodb log buffer size = 4M
Innodb flush log at trx commit = 2
Innodb thread concurrency = 4
Innodb flush method = O DIRECT
Innodb file per table = 1
At last I accomplished up to 100% increase in performance. I didnt try to change my HD to SSD as yet, but Im certain that itll gain even further performance. BTW is an interesting manual, use it to perform automated tests. It even allows running MySQL in memory instead of disk, this is really good.

Valuebound is a leading Drupal Development Company providing Enterprise Drupal web solutions. For more information on Drupal Development, contact us at


Viewing all articles
Browse latest Browse all 171

Trending Articles