How to troubleshoot slow response for PHP application hosted in IIS 7


Troubleshoot slow response for PHP application hosted in IIS 7

In this article I will discuss about troubleshooting slow response for PHP application. PHP performance issues are quite challenging to troubleshoot as we don’t have any in-built tools that comes with IIS. We could use tools like Windows Debugging tools or Debug Diagnostic for any slow response for an applications running in IIS. However for PHP application this may not be helpful.

When running PHP application in IIS, we can use a profiling option named Xdebug extensions which comes along with PHP. This profiler extension will help us to identify which function(s) or method(s) are taking longer time to execute.

Enable profiling only when you troubleshoot the issue. Ensure, profiler is disabled once the troubleshooting is completed otherwise it may impact the performance of your application.

I assume that we have PHP configured in IIS. However if you need assistance in configuring it, please check this link.

To verify which version of Xdebug dll is required, check the bitness of the application, check if PHP configured in the system is Thread safe or Non Thread safe. Also to check which version of xdebug binary is required, you can copy the output of phpinfo() from your system and submit it in the form Tailored Installation Instructions

Download Xdebug profile from Xdebug Download. Place the binary in ext folder under PHP folder (In my machine I have PHP installed on C:\PHP). Open php.ini from PHP folder and append the following lines at the end of file and restart IIS




zend_extension = C:\PHP\ext\php_xdebug-2.2.4-5.5-vc11-nts-x86_64.dll

Configuring of Xdebug profiling extension is complete. Let take look at how to troubleshoot the slow response in PHP page. Here, I’m creating a simple php page named sleep.php that takes 10 seconds to execute. Following is the code for sleep.php


echo date('h:i:s');

echo "<br />";


echo date('h:i:s');


When we browse to sleep.php, xdebug will create a file under xdebug_profiles folder (we have specified the location of xdebug_profiles folder in php.ini file) with naming conventions as cachegrind.out.<<PID of PHP process>>

To read the xdebug generated file we need to use WinCacheGrind. This tool will help us identify function(s) or method(s) that are taking longer time to execute. You can download WinCacheGrind from

Open the file in WinCacheGrid and identify which method is executing slow.

You can check the overall time the page took to execute along with time taken to execute all function(s) or method(s). We will also get information on how many times each function is called.

Once we know the method which is taking a longer time to execute, we can investigate that method to understand why is it taking time and we can improve the performance accordingly. I hope this helps!

Comments (0)

Skip to main content