Best practice to identify performance bottlenecks in a PHP/MySQL application (Drupal)

| | August 4, 2015

I took over an app based on a heavily modified version of Drupal. The last developer didn’t do a good job. At least at first sight I saw a lot of monkey-patching and things you should never ever do (password files, called password.txt, in a public webfolder, etc.).

The app is incredibly slow. I guess it is caused by bad code (since it doesn’t load large assets) and I guess it must be MySQL related – but I don’t know for sure.

Since the app is not documented, what would be the best and fastest approach to look for bottlenecks? Are there any tools that could help me? Where should I start?

I pulled a version to run it locally on a Mac, maybe that makes things easier.

2 Responses to “Best practice to identify performance bottlenecks in a PHP/MySQL application (Drupal)”

  1. Øle Bjarnstroem on November 30, -0001 @ 12:00 AM

    since I’m using MAMP I thought I share what I did to check the MySQL queries. Beware: Only do that for testing purposes. Or clean your log files regularly, they’ll build up.

    I edited the my.cnf for MySQL in MAMP and added the following lines in the Mysqld Section

    # The MySQL server
    # Some other configuration will be here
    slow-query-log = 1
    slow-query-log-file = /Applications/MAMP/logs/mysql_slow.log
    long_query_time = 0.001
    general_log_file= /Applications/MAMP/logs/mysql_query.log
    log = /Applications/MAMP/logs/mysql_sql.log

    Then just cd into the /Applications/MAMP/logs/ folder and watch with

    tail -f ./mysql_slow.log 

    what is going down.

  2. If you suspect mysql queries, turn on log-slow-queries in mysql and set long_query_time to low value, eg 0.010 seconds. Or you can turn query log for all queries:


    Then xdebug has profiling abilities.

Leave a Reply