blog-banner

Troubleshooting a Slow Drupal Site

    Drupal Troubleshooting


    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 up to 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 the slow response problem in Drupal 7 has been quite common for many other users as well, each of them had different reasons though.

    At last Damien Tournoud commented in the post Why Drupal 7 is so slow? pointed me to core bug #1081266: Avoid re-scanning the 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 the 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 was the same bug that my site was experiencing !!

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