Php – Steps to optimize an IIS server for PHP

cakephpiisoptimizationPHP

I've inherited a very slow PHP site running on IIS and I'm trying to maximize it's performance. The issue is all in the Time to First Byte (TTFB), with 1500ms TTFB for an almost empty page and an average of 2500ms TTFB on most pages. The Database Query times (the DB is hosted on another server) are acceptable and connection/download speeds are in the tens of ms at most; the speed of processing the PHP seems to be the only issue, it uses almost 100% of one core of the server's dual core CPU to serve a single page request.

It is currently running IIS 6.0, PHP 5.2.5 and Cake PHP 1.2, and I am working on bringing it up to IIS 7.0, PHP 5.3.6 and Cake 1.3.10, as well as installing a PHP caching component after I get the PHP version upgraded. PHPinfo() shows "server API" as ISAPI, we have Fast CGI installed, Fast CGI is preferred, correct?

Are there any other steps I should go through to ensure the server is running optimally for PHP? I want to ensure I'm getting the most out of the server before I attempt to run Apache along with IIS to run my PHP site instead (on the production server there are other sites residing on the same server).

Best Answer

As others have said, the root problem is the inefficiency of how the application was built, so if you can fix that, do so.

Once that is out of the way, I have noticed notable performance increases after switching to IIS 7 with FastCGI and non-thread-safe PHP 5.3. I think the bulk of the improvement is with FastCGI and NTS PHP 5.3, which is entirely possible and easy to do under IIS 6.

This has cut page processing times by about 40% for me.

Related Topic