Successfully reported this slideshow.
Your SlideShare is downloading. ×

Rev it up with php on windows

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Upcoming SlideShare
Wordpress On Windows
Wordpress On Windows
Loading in …3
×

Check these out next

1 of 17 Ad

Rev it up with php on windows

Download to read offline

PHP on IIS has had an amazing performance jump in the past 2-3 years but you can always squeeze a little more torque out of an engine with the right tuning. In this session we’ll dive into improvements in FastCGI and fantastic new libraries such as WinCache 1.1 for exceptional performance in your applications as we go under the hood with IIS.

PHP on IIS has had an amazing performance jump in the past 2-3 years but you can always squeeze a little more torque out of an engine with the right tuning. In this session we’ll dive into improvements in FastCGI and fantastic new libraries such as WinCache 1.1 for exceptional performance in your applications as we go under the hood with IIS.

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Similar to Rev it up with php on windows (20)

Advertisement

More from Josh Holmes (20)

Recently uploaded (20)

Advertisement

Rev it up with php on windows

  1. 1. /Web Rev it up with PHP and IIS Josh Holmes Architect Evangelist Microsoft Corporation josh.holmes@microsoft.com @joshholmes Mark Brown Web Platform Team Microsoft Corporation mark.brown@microsoft.com @markjbrown
  2. 2. First, a little history… • PHP on Win/IIS == Big Joke2006 • FastCGI2007 • IIS URL Rewrite & IIS 7 • SQL Driver for PHP2008 • WinCache 1.0 • PHP 5.32009 • WinCache 1.1 • PHP Manager2010
  3. 3. IIS 7 • Default minimum installation • New modular architecture • Streamlined processing pipeline • Config similar to .htaccess, web.config faster Authorization Resolve Cache Execute Handler Update Cache Authentication Send Response
  4. 4. FAST-CGI PHP • Production PHP on Windows/IIS !!!! • Handles requests from app pool – No more createproc() per request • Automatic Performance tuning – Mem, CPU, CTX – Better density for hosted environments • Auto recycling PHP pool when php.ini changes – No more manual IIS restarts • Consistent features across all versions of IIS – Code in XP, deploy to WinSvrR2
  5. 5. WINCACHE • Boost your speed with no code changes – Opcode Cache – File Cache – Relative File Path Cache – Session Cache – User Data Cache • WinCache Statistics Script for performance details
  6. 6. URL REWRITE • Required for many Web CMS’s • Rules-based, text file or database • Reg-Ex & wildcard matching • Rewrite: – Outbound URL’s – Request headers and Server variables – HTTP Response – Inside specific html tags in response • Import Apache mod_rewrite
  7. 7. PHP 5.3 • Updated code base • Native Win32 instead of POSIX • Latest compiler VC9 • Use Non-Thread-Safe builds for better performance.
  8. 8. PHP Manager • Register multiple PHP versions with IIS • Easy checking of phpinfo() • Configure PHP error reporting • Manage all php.ini directives and PHP extensions within IIS • Remote PHP administration via IIS Remote Administration Tool http://phpmanager.codeplex.com/
  9. 9. SQL Server • PHP Driver for SQL Server 2.0 • Support for native PHP • Support for PDO • Support for PHP 5.3 • Source released under Apache 2.0 • Signed version includes support • Drupal 7 will be first major PHP app with SQL Server support
  10. 10. IIS DATABASE MANAGER • Consolidate MySQL or SQL Server Management inside IIS where you manage your sites – Manage local/remote databases – Create and edit tables – Add and edit data – Modify indexes and keys – Create and execute queries
  11. 11. PHP Web Apps • Web Application Gallery – The most popular PHP apps – Easiest way to install – Packages built and tested for Windows/IIS – Promoting actively: •http://web.ms/wordpress •http://web.ms/drupal •http://web.ms/joomla
  12. 12. PHP INTEROPERABILITY • Extend PHP Applications: – Build reports with SQL Server Reporting Services and the SDK for PHP – Jazz up PHP app with Silverlight adaptive streaming – Add Bing Search to your site, like the WordPress plug-in http://www.interoperabilitybridges.com/php
  13. 13. PHP + COMMUNITY • WinCache is on PECL • SQL Server Driver for PHP is on codeplex • IIS and WinCache documentation on php.net • Participating on PHP forums • Working with PHP Group to improve PHP and PHP installer • Working with PHP application developers to integrate URLRewrite and WinCache • Working with PHP application communities to enable easier deployment on Windows/IIS (Web Deploy)
  14. 14. START RIGHT HERE PHP on Windows microsoft.com/web/php
  15. 15. SUMMARY • Windows & IIS is now viable for production PHP application hosting • PHP performance on Windows has significantly improved in last 2 years. • Web App Gallery will grow PHP developers on Windows and grow your business.
  16. 16. Questions?
  17. 17. © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Editor's Notes

  • So the prevailing notion among many in the web is that running PHP on Windows is largely a joke.

    For many years the ability to run PHP on Windows meant two options:
    Run PHP using CGI, which for many was stable but really slow.
    Or run PHP using the ISAPI module which was faster, but incredibly unstable.

    Other things were missing as well including a good option for clean URL’s and caching

    So beginning in 2007 Microsoft set about to change that and for roughly the last 4 years we have been making some huge changes and improvements to both our web platform in Windows Server and IIS as well as working with the PHP Group itself to make PHP better on Windows as well as provide URL rewriting capabilities and caching as well.

    Today I am going to talk to you about each of the things we’ve been doing and talking to you about how they have made PHP on Windows not just possible but for many of you, actually a smart and pragmatic approach to your hosted offerings.
  • IIS
    IIS 7.0 is a from the ground up rewrite over the previous versions and with a new architecture.

    Default Min Install: The new IIS 7.0 architecture and default minimum install enables a significant reduction in attack surface making it far more secure.

    Modular Architecture: Previous versions of IIS were difficult to customize or streamline for high performance applications.
    This new modular architecture makes it far easier to create modules and handlers at any point in the processing pipeline.
    You also don’t have to write these modules in C++ anymore either. You can create them in managed code far faster and with excellent performance.

    Streamlined Processing Pipeline: The modular architecture allows for a streamlined processing pipeline. Load only what modules you need for much better performance.

    Web Config: The new configuration system in IIS 7.0 loads configuration files—similar to .htaccess files in Apache—and manages them in a cache after first read. All subsequent requests use the cached configuration and the new configuration cache consumes significantly less memory than the equivalent in Apache. IIS 7.0 also includes caching support for all types of dyn amic content.
  • Fast CGI
    With the release of FastCGI first time you could actually consider hosting php on win/iis, production quality, no more crashes.
    Previously you had two options to host PHP, CGI or PHP ISAPI.
    CGI was stable but very slow because you had to spin up a new process for each new PHP request.
    ISAPI was faster but since many popular extensions for PHP were not thread safe this caused major issues with stability.

    FastCGI handles PHP requests out of an app pool rather than spinning up a new one each time.

    FastCGI provides optimal PHP performance without having to manually tune:
    Fast CGI provides Automatic performance tuning.
    Determines: CPU usage, memory consumption, context switches.
    Based upon that information it changes the number of PHP processes to optimize your application automatically. (Sets Dynamic Max Instances)
    Very important if you are a hoster managing many customers since it allows for a higher density of PHP applications on Windows than you could get before or a customer with an app that has large changes in requests over time.
    Automatic recycling of PHP processes in IIS when php.ini changes. No longer need to restart IIS.
    Version 1.5 now has a consistent set of features across all versions of IIS. This is important as a significant number of PHP developers still use XP. This will allow them to develop and deploy seamlessly to Windows Server. Version 1.5 of Fast-CGI is included in Windows Server 2008 R2 (IIS 7.5), an update is available for IIS 7 along with a back-port for those using XP.

    Another useful feature I wanted to point out here as well is you can provide to your customers developing or running PHP on Windows/IIS is the Advanced Logging module in IIS which you can use to consolidate event reporting for PHP itself as well as from IIS. This will help your customers consolidate application performance reporting, good for tracking failed requests or other issues in your php application. No need to have separate error log files for webserver and php.
  • Compile and file operations on Windows are slower than on linux. Many more security checks, etc.
    Many PHP developers on Linux use other caching mechanisms such as memcache or APC.
    There are no good open source solutions for caching on Windows
    WinCache is our solution to help provide even more performance for PHP on Windows.

    Opcode cache – this is a cache of the compiled PHP file.
    WinCache let PHP core compile the PHP file to generate opcodes first time it is executed.
    Then caches these opcodes in memory and is shared with other PHP processes
    Increasing performance, especially on subsequent access to the executable code.
    Can expect a 100%-200% increase in performance.


    File cache –
    File IO operations on Windows are much more expensive than on Linux.
    For files on UNC’s or NFS in hosting environments scenarios it is even worse.
    File Cache stores the contents of opened files in shared memory.
    This increases performance 80-90% over accessing the files each time from a shared location.

    Resolve File Path cache –
    On first access a PHP application will work to determine the absolute path to a file to then open it
    This feature is used to store the absolute path from relative file paths used in PHP applications.
    Again, anything to reduce usage of the file systems calls produces performance gains.


    Session Cache:
    The session cache will take and store session data in shared memory cache instead of file system for added performance benefits.
    Currently this feature cannot be used in a webfarm where there is no session affinity.


    User Data Cache API’s:
    Provides caching functions(API’s) with the
    Can be used by PHP applications for storing variables and objects in shared memory using WinCache instead of PHPs cache.
    You can cache database data, php data, classes, etc.
    Overall just closing the feature gap to APC, etc. trying to have a complete solution.


    WinCache Statistics Script –
    This thing is very cool and you should check it out.
    Great for helping you benchmark and fine tune your PHP applications on Windows.
    Is installed with the WinCache for PHP.
    PS: this file is protected by default with HTTP basic authentication so if you do provide this for your customers. Just an FYI.
  • So prior to PHP 5.3 the PHP engine itself wasn’t mature on Windows, causing compatibility and performance problems.
    Implemented with APR (Apache portable runtime) instead of directly on Win32 created subpar performance
    Also many Windows-specific PHP bugs hadn’t been fixed
    There were as I mentioned earlier issues with hosting on IIS itself with the slow CGI or unstable ISAPI handler. Using FastCGI provided the fix for that part.

    The next piece was…

    PHP 5.3
    Has an updated code base
    Much of PHP for Windows completely rewritten to use native Win32 instead of through the POSIX layer
    Also compiled using our latest compiler VC9 versus VC 6 which was 10 years old
    Use the NTS version. No thread safety checks since PHP runs Single threaded on IIS in FastCGI.
    Reason for NTS is that many of the most popular community extensions themselves are NTS themselves, making NTS the default on Windows is the safest route for stability.

    Btw, Anybody know who this guy Rasmus guy is?


    PS: The Web App Gallery is still using 5.2.x (app requirement) but we are getting close to having multiple versions of PHP available for
  • PHP Manager for IIS 7 is a open source extension for IIS Management Console, that greatly simplifies the tasks of setting up, configuring and managing one or more PHP versions on IIS server. Use it to register PHP with IIS, run multiple PHP versions, get the information about PHP runtime settings, add and modify php.ini directives and enable or disable PHP extensions.

    Features:
    Simple registration of many PHP versions with IIS
    An easy way of checking if PHP works correctly by geting the output of phpinfo() function
    Configuring the PHP error reproting settings for production or development environment
    Managing all php.ini directives and PHP extensions from within IIS manager
    Remote PHP administration via IIS Remote Administration Tool
    Works well with PHP installed via Web Platform Installer or PHP Windows Installer

    http://phpmanager.codeplex.com/releases/view/53121

×