Skip to main content
knackforge blog knowledge base

Troubleshooting a slow Drupal site

One of the interesting assignments I took recently is troubleshooting a slow Drupal 7 site. The site was hosted on our AWS micro instance. I'm sure the problem was not to do with server load as the other sites hosted on the same server were doing great for both authenticated and anonymous users.

I quickly installed the devel module to troubleshoot the problem. Enabled the display query log, display page timer and display memory usage options. The SQL query execution time was pretty optimal but the PHP execution time was upto 10 times larger than expected. Unfortunately I was not able to enable the XHProf PHP profiler to precisely identify the problem. Couldn't believe that slow response problem in Drupal 7 has been quite common for many other users as well, each of they had different reasons though.

At last Damien Tournoud comment in post Why Drupal 7 is so slow? pointed me to a core bug #1081266: Avoid re-scanning module directory when multiple modules are missing. I changed his SQL query to a drush script to precisely identify the problem,

SELECT name, filename FROM system WHERE type = 'module' AND STATUS = 1 ORDER BY filename

From drupal root directory I ran the following script,

for file in `drush sqlq "SELECT filename FROM system WHERE type = 'module' AND status = 1 ORDER BY filename"`; do file $file; done | grep -i "cannot"

My luck it was the same bug that my site was experiencing !! 

It was revealed that WYSIWYG and a bunch of other module were enabled but not in-place. Downloading the missing modules to registered path restored the site to expected response time.