|PHP 5.2.2 and above running slow on IIS with FastCGI|
|Written by Dicky|
|Friday, September 10 2010 13:16|
I was developing PHP application and host it on a Windows hosting box. My application was running smooth and fast using PHP4 binary, however, as soon as I have the script mapped to PHP5 binary, the page loads really slow. It seems to render the text quite fast but it takes sometimes to actually finish loading the page.After further troubleshooting, I finally found out that it's only happening when you enable MySQL extension. To fix this, you can simply comment out this line from your php.ini file:
But that won't work for me since I depend on MySQL for database connection. Googling the issue doesn't give you that much results / valuable information, this is probably because PHP running on IIS using FastCGI is really uncommon. PHP usually runs on Linux box. I download a new binary for PHP 5.3.3 and that seems to fix the problem but then there are PHP application that not compatible with 5.3 plus I don't want to make such a significant change in production box. Then, I tried to download 5.2.14 both thread-safe and non thread-safe and the problem still exists. That still doesn't deter me to find for solution, after few more hours of researching, I finally found the root cause of the problem as defined on this bug on PHP website.
Turns out, the issue has been exist since PHP 5.2.2 all the way to 5.2.14. The problem lies on libmysql.dll and it seems on MySQL 5.0.77. However, just to be safe with compatibility issue, I downloaded the old PHP 5.2.1 version as suggested on this article and replace the libmysql.dll with the current PHP build running on the server. And that finally fixes the problem! My application is now running smooth and fast :D