Microsoft and Zend Release FastCGI for IIS
A long while back I mentioned Microsoft and Zend had entered into a collaboration agreement to create a native FastCGI interface for IIS. That project has finally begun to show some fruit.
Microsoft and Zend have released a “technology preview” release of FastCGI for IIS. From IIS.net:
The FastCGI component is part of the collaboration between Microsoft and Zend to improve performance and stability of PHP on the Windows platform. This effort aims to help PHP developers achieve improved performance on the Windows platform by leveraging the new IIS FastCGI feature together with Zend’s on-going work to improve the PHP engine on Windows.This is good news. We've talked a bit about different ways to run PHP (or Ruby or Python) on your web server before, but to rehash, you can run it in one of three ways.
The first, CGI, starts an instance of php-cgi.exe at each request, which gives you total process isolation from the web server. That’s a good thing - if a PHP process goes down, the web server keeps on trucking. But you pay a performance cost as every time a request comes in php-cgi.exe has to be started (disk hit and memory allocation), and it has to parse php.ini and all of your extensions every time it fires, and killing the process when it’s done. It’s amazing how fast your web server will do all of that, but still, it’s the slowest way to go.
The next way, ISAPI, fires off PHP as part of the web server process. This has a great speed advantage, but it means you have no process isolation. If PHP goes down, the web server goes down with it. While PHP is thread-safe, many popular PHP extensions are not, and this can (and usually does) cause stability problems. On PHP’s web site they now divide the extensions into thread-safe and not thread-save downloads.
FastCGI tries to give you the best of both worlds. Rather than loading PHP as part of the web server process, the web server only loads a FastCGI handler. It in turn fires up and manages php-cgi.exe processes, keeping a minimum number open and adding/subtracting more as needed (all configurable). Your php-cgi.exe processes are already instantiated, so you get the performance benefit, but they are isolated from the web server, so you get the stability benefit too.
They’re pulling a bit of a Google trick with the release title. While they’re saying it’s ready to use in production, they’re still calling it a “Technical Preview” release (a.k.a. the perpetual don’t-sue-me Google “Beta”). The docs are a bit confusing as to the IIS versions supported. Many refer to 5.1 and 6, but the download just refers to 6. It seems to run fine on IIS 5.1 on my PC, though. I think Microsoft wants to pretend the XP and Server 2000 users are rapidly vanishing.
While the docs focus on PHP, in theory you can configure it to work with other CGI apps, like Python and Ruby. You can grab FastCGI for IIS here, and they have configuration instructions over here. I’m tempted to run FastCGI for all of my sites running PHP MapScript (which is not thread safe) and have everything else run ISAPI.
Powered by ScribeFire.