Shane Caraveo talks PHP, FastCGI and IIS

If you use or develop PHP applications on IIS, then the name Shane Caraveo should be no stranger to you. Shane Caraveo wrote the first Win32 port of PHP back in the late 90's, and was also responsible for writing the first ISAPI and FastCGI modules for IIS, and also getting support for these modules committed to the PHP core. To say Shane's work has been instrumental in getting PHP to where it is today on the Windows / IIS platform is a rather large understatement.

Although Shane has now moved on and is now working for ActiveState, his legacy still remains in the PHP arena and I thought I'd pick his brains to see what his thoughts where on the future of PHP on IIS. Shane was gracious enough to offer some time to talk PHP, FastCGI and IIS, and this is what he had to say.

So Shane, what was it like when you first came across PHP and found that there was no port for Windows?

My first server on the Internet was actually a Solaris Sparc 2 running PHP/FI and mSQL back in 1996/97 when I used to do a lot of small website as database front-ends. What brought me to Windows was I got sick of developing my scripts in notepad/homesite only to find a typo after uploading them to my Solaris box. So I went out and got myself a copy of Visual Studio and ported PHP/FI to Windows in a couple of weeks, at least enough for me to test my scripts with.

Wow, so PHP basically came about on Windows so you could test for typos? So how did your involvement with the PHP project come about?

Well, after I ported PHP/FI to Windows I sent Rasmus the tarball and he responded something like, “great, now you can port PHP 3�. I didn't think it could be any harder than what I'd already done, so I proceeded to work on the port for the next year or so.

Did you get to work directly with Rasmus or any of the big names in the Windows / PHP arena?

Yeah, I worked with Rasmus, as well as Zeev, Andi, Stig and a bunch of other devs quite closely for some time. It's hard to remember when various people came into working on PHP. It was my first real introduction to open source development, it was a great experience, and has helped me immensely throughout my career.

Wow, that must've been a blast to work with those guys. When did you first look at developing the ISAPI module for PHP?

After PHP3 was released I did a 3.1 branch in CVS working up the ideas for multithread support and the SAPI layer that is still used today to support different web servers. I had ISAPI working at one point, then PHP 4 development started so 3.1 was never released. A lot of that work was carried over into PHP4, or used as the base ideas for some of the windows support.

What inspired you to continue on and develop a FastCGI module for IIS?

PHP actually has had FastCGI support for a very long time, I think maybe even PHP/FI supported it, but I'm not sure. What gave me the push to develop FastCGI for IIS was that it had became really apparent over time that multithreading wasn't going to work well for a small production site I was running on IIS and I needed better performance. So I looked at the FastCGI support in PHP 4 and there wasn't any FastCGI plug-ins for IIS at the time, so I decided to write one. It took a little while but I got it working, and got FastCGI integrated into the cgi module so it would always be available to windows users.

However soon after that I migrated my one windows server to Linux, and no longer needed FastCGI. It was primarily a cost issue as we could get the services we needed cheaper on Linux. With windows we had a dedicated server, with Linux we could pretty much get by on shared hosting. Then after that I worked on SOAP support (PEAR::SOAP) for a while.

It must be a bit of a rush to know how much your work has influenced the uptake of PHP on IIS on a global scale.

Yeah, there is a bit of pride around being involved in PHP at that time, but mostly I think I was just lucky to be in the right phase of my life at the right time. And to work with that group was really amazing.

It seems that there is quite a bit of room for improvement for PHP performance on IIS. Have you been following the PHP core improvements Zend have been making specifically for Windows and Microsoft's new FastCGI module?

Actually yes, I've known about Microsoft's FastCGI module for a little while. We just finished the Vancouver PHP Conference, and one of the speakers was Rick James who is a part of the IIS Team at Microsoft and has worked on the Microsoft FastCGI implementation. I was quite happy that the IIS Team is implementing FastCGI. Rick also mentioned some of the performance improvements they are helping with in the PHP core, and I was able to give a couple suggestions for further support for PHP in IIS. Rick has also offered to handle requests for help from the PHP development community when windows issues arise. Zend is already taking advantage of that.

The major problem with PHP on Windows has been multithreading support. With PHP there are lots of problems around threading support due to the multitude of 3rd party libraries in use, and the lack of developers (for PHP) that work on windows. The core of PHP is ok, but it's not well tested in threading situations. There are now single threaded builds of PHP for Windows appearing, which I believe are available on I'm told that by simply doing this can result in a performance increase of 40% in PHP. Combine that with FastCGI and the fact Zend are also doing other work to improve performance of PHP on Windows and you'll get a very stable and fast PHP environment running on windows.

Wow that is quite considerable! Would using an opcode cache increase this performance further?

Certainly. The only downside is memory usage as the opcode cache would not be shared between PHP instances with FastCGI. However I would definitely suggest the opcode cache as memory is cheap.

The future for PHP on IIS is certainly looking a lot brighter. What do you see as being some of the bigger challenges facing PHP on IIS in the future?

The biggest challenges probably aren't going to be technical, but rather cultural ones that haven't been figured out yet. Most core PHP developers do not develop on Windows. Unless more Windows developers make an effort to help PHP improve on Windows, the Windows version will always be second class. Another item is that the PHP community is largely an open source community. They gravitate towards open source technologies and tend to avoid commercial software.

The other issue is Microsoft itself. Even though they are making a push to get some open source technologies working well in Windows, it is by no means a primary goal for them in my opinion. They will do enough to make it work better, but perhaps not enough to make it a first class citizen.

Do you have any tips for PHP developers to make their modules/libraries more IIS friendly?

Well, the biggest issue there is that most PHP developers I know will only work on Linux. I think that the biggest suggestion I could make is that people need to be more open about designing things in a way that would make porting operating system specific features easier. There are arguments for and against this that are all valid, but there is a large base of developers that work on windows.

Windows DLL's are not always kept up to date. Are there any open source tools you'd recommend so that people can download source files and build their own DLL's?

Microsoft makes their compilers available for free, use them! There is no reason that any PHP developer on windows should have a problem with building PHP or any extensions for PHP. There may be a little bit of learning to do, but it is relatively easy.

Well, that's about all the questions I have for you Shane. Thankyou very much for your time.

Average rating
(3 votes)