Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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).

share|improve this question

3 Answers 3

up vote 0 down vote accepted

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.

share|improve this answer

You can try using Phalanger. It is a PHP compiler for .Net, and as you are running a windows server with IIS, this seems to be the best option, as it will increase performance of the PHP application.

share|improve this answer

You'll almost certainly get more bang for your buck out of unsucking the code; a bit of light profiling and optimisation from someone who knows what they're doing should get things under some sort of control (1500ms of a full core is a lot of CPU cycles). Only once you've got some handle on how bad the code is should you start looking at the server -- there's a lot fewer places you can make a real mess of that (to the level of needing 1.5 seconds of CPU time to produce anything useful, anyway -- that's ridiculous).

share|improve this answer
    
The code isn't great but it seems CakePHP's calls are eating up most of the processing (a very simple session-driven page displaying a header and a few links takes 1.5s to load), there doesn't seem to be much TO optimize aside from Cake's core (it IS an old version). Regardless I'd like to make sure my environment is optimal before I start messing with the code. It's not mine so that's it's own challenge, and I'd like to be sure it's the problem before I start. –  Ben Brocka Aug 3 '11 at 14:19
    
@sirtap: Just because it's Cake eating cycles, don't assume the problem is Cake's problem. More likely the code is doing something stupid with Cake. Also Cake. (Needed to say Cake one more time.) –  Satanicpuppy Aug 3 '11 at 16:20
    
Yeah, I doubt that everyone who uses CakePHP has a minimum of a 1.5 second page load time -- I doubt it'd get much use if it really was that inefficient. –  womble Aug 3 '11 at 22:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.