Making PHP rock on Windows/IIS

********************
UPDATE – 10/30/2006: We have just released the FastCGI Technical Preview for IIS 5.x / IIS 6 / IIS 7.  Read more on my blog post,  and go get it from iis.net.  More blog coverage also on Bill's blog.

********************
UPDATE – 12/31/2006: We have just released the FastCGI Technical Preview 2 for IIS 5.x / IIS 6 / IIS 7.  Read more at Turbo-charge your PHP applications with IIS FastCGI Technical Preview 2.

********************
UPDATE – 09/24/2007: FastCGI GoLive beta for IIS 5.x / IIS 6 is here!  Read more at Deploy your PHP applications today with the IIS 6 FastCGI Go-Live release!

********************

UPDATE – 11/12/2007: FastCGI for IIS 6.0 RTMs on Download Center! Read more at FastCGI for IIS 6.0 is released on Download Center.

********************

The latest matrix of FastCGI releases for Windows XP, Windows Server 2003, Windows Vista and Windows Server 2008 at IIS FastCGI and PHP: What you absolutely need to know to host PHP applications on IIS 6 and IIS 7.

Right as I was about to go home, one of our developers comes in to tell me some good news about our new IIS7 FastCGI module.  So, I figure I would shed some light on our recent work to improve hosting PHP (yes, you read right, PHP) applications on Windows/IIS. 

The IIS team is committed to providing production quality support for PHP applications, which is currently lacking on the Windows platform.  It turns out, while 70%+ of PHP developers develop on Windows, actually hosting PHP applications on Windows is not recommended by the PHP community for production.  Why? 

Here is the reason:

IIS is a multi-threaded web server, because multi-threading is really the only way to achieve high-concurrency high-performance server applications on Windows (processes aren’t as cheap as they are on Nix).  ASP.NET, ASP, and other IIS application frameworks and components are all thread safe, and the IIS extensibility model is designed to allow high-performance / asynchronous processing.  PHP has not been designed with multi-threading in mind, and while today the PHP core is thread safe (http://www.php.net/), many extension libraries PHP applications use are not and therefore cannot be reliably hosted in a multi-threaded environment.  You may get lucky, but unless you are making sure the extensions you are using are thread-safe (except for extensions bundled with the PHP core distribution, I cannot find any list of known-safe extensions anywhere), you are sure to hit deadlocks and memory corruption when running PHP in multi-threaded mode with the PHP ISAPI extension for IIS.

The only supported single-request-per-process option on Windows/IIS today is to use CGI (http://www.w3.org/CGI/).  In a nutshell, CGI hosts spawn a new application process for each incoming request, send in request data via environment variables/stdin, receive the response back via stdout, and kill the process.  Result – the performance on Windows is horrendous! 

So, we set out to build a FastCGI host for PHP, which is another commonly supported mode for PHP applications that uses the next generation FastCGI protocol (http://www.fastcgi.com/devkit/doc/fcgi-spec.html), that still allows for a single request per process execution but maintains a pool of reusable processes.  This should be quite promising according to our internal test results, and I cannot wait until it’s ready for primetime. 

Bill Staples and I gave the first public preview of our work to make PHP rock solid on the Windows/IIS platform to a number of key PHP developers last week … I demoed our brand new native response caching feature in IIS7 that launched the throughput of my sample dynamic PHP app (QDIG) from 40 RPS to 1600+ RPS (it was client bound at that point, so I couldn’t even come close to maxing the server). 

Here is some early news coverage of the event: http://searchopensource.techtarget.com/columnItem/0,294698,sid39_gci1218130,00.html. 

The article quotes me as saying “nothing concrete has come out of this yet” – but something concrete is definitely coming.  For starters, our FastCGI PHP host platform that should get us most of the way there.  There are definitely other things we need to do to make the experience rock end to end, including providing support for commonly-used Apache features like mod_rewrite for url rewriting, and a number of others, but one thing is clear – PHP on IIS7 is going to kick ass!

If you have any ideas / specific suggestions for how we can make PHP run better on Windows, please don’t hesitate to comment.

Stay tuned for more updates on this effort.

18 Comments

  1. Anonymous

    Posted on 10/8/2006 6:56 PM:

    How about Ruby via FastCGI? More specifically, Rails. Rails is not thread-safe, and many Rails sites still rely on FastCGI (though thats changing with load-balanced proxying to a group of application servers, a.k.a Mongrel). If your FastCGI implementation works well for PHP, it could be a way to bring Ruby and Rails goodness to the IIS platform.

  2. Anonymous

    Posted on 10/8/2006 7:53 PM:
    Exactly right. While I cannot promise anything, the FastCGI module should work for any FastCGI compatible executable, including RubyonRails. More on this later …

  3. Anonymous

    Posted on 10/22/2006 5:17 PM:

    What improvement will this represent over the current Zend Core distributions for use with IIS 6? I believe they also use FastCGI.

  4. Anonymous

    Posted on 10/31/2006 10:25 AM:

    We should be faster. The main idea though is to have this platform level technology come from the IIS team, so that we can innovate it together with the platform (such as coverting it to an IIS7 module on top of the new IIS 7 extensibility APIs that provide numerous advantages), provide richer features, and support it with the product in the future.

    Zend Core distributions will continue to provide improvements to the core PHP engine that should futher improve the performance and stability of PHP on Windows / IIS, and be able to leverage the IIS-level improvements of our FastCGI support to provide the best-ever support for PHP on Windows.

    Check out the update to the post with links to the FastCGI technical preview that we just released today, and the new Zend Core For Windows technical preview from Zend.

  5. Anonymous

    As you’re looking for managed email service pages and information, be certain to utilize everyone of the sources at your disposal.

  6. Anonymous

    Some web hosting companies are so sure of their services and products, they are willing to offer clients access to very cheap fees if they sign on for long- term contracts. While cheap web hosting 10 year contracts can save site owners a great deal of

  7. Anonymous

    After almost 5 years at the company, I am both sad and excited to say that I’ll be leaving the IIS team and Microsoft at the end of this week. Looking back, I can say that my experience at Microsoft has been truly amazing

  8. Anonymous

    Would you be able to tell me if this information is still current? Is there anywhere with update info?

    Thanks

  9. Anonymous

    A) First let’ s think of offline publishing: Don’ t try sending your articles to your local trade magazines, as potential clients do not read them. Send them to magazines or newspapers that your potential clients may read. Send it to the local newspaper.

  10. Anonymous

    Internet Security and Acceleration (ISA) Server 2004 Standard Edition Service Pack 1 (SP1) offers updates and improvements to ISA Server 2004 Standard Edition.

  11. Anonymous

    We have to ask why web hosting became affordable to so many people when the cost of it dropped. The reason is pretty direct with the increasing demand.

Leave a Reply

Your email address will not be published. Required fields are marked *