SlideShare a Scribd company logo
1 of 29
PHP + FastCGI
Performance Optimizations
             Alessandro Pilotti
            Twitter: @alexpilotti
            MVP ASP.NET / IIS




     MCSD, MCAD, MCSE, MCDBA, MCT
        Red Hat Certified Engineer
PHP on IIS
 FastCGI
   Best available option
 ISAPI
   The way to go before FastCGI
   Low reliability due to reentrance problems
   DLL loaded at W3SVC instance level
     Security issues

 CGI (not FastCGI)
   Awful performance
How to get PHP on Windows
 Binaries
   http://windows.php.NET/download/
 Visual Studio C++ CRT DLL: VC6 or VC9?
   Apache: VC6
   IIS: VC9
 Thread safe or not thread safe?
   Thread safe for ISAPI
   Non Thread Safe for CGI/FastCGI
     Massive performance improvement!
 x86 vs x64
   Do you need > 4GB of process space?
WebPI
 Microsoft Web Platform Installer (WebPI) is a free tool that
  simplifies deployment of web solutions
   IIS features and extensions
      WinCache, PHP Drivers for SQL Server, PHP Manager
   Frameworks
      .NET, PHP, etc
   Web applications
      Drupal, Joomla, Wordpress, DotNetNuke, Orchard, etc
   Database
      MS SQL Server Express, MySQL, etc
   WebMatrix
 Both PHP 5.2 and 5.3 can be easily deployed via WebPI
 Local cache:
   "%localappdata%Microsoftweb platform installer"
Deploy PHP via WebPI
Deploy PHP via WebPI
Deploy PHP via WebPI
Deploy PHP via WebPI
Compiling PHP
 If you want:
    A PHP release available in sources
    A development build for testing purposes

 What do you need:
    Sources, e.g.: http://php.NET/downloads.php
    Subversion client (e.g. TortoiseSVN)
    Instructions:
    https://wiki.php.net/internals/windows/stepbystepbuild
    PHP build extras
      http://windows.php.net/downloads/php-sdk/
      Deps and binaries: bison.exe, flex.exe, etc. and additional include and libs
    Visual Studio 2008 or 2010
      The Express edition (free) is enough
Compiling PHP
   Unpack the downloaded sources, e.g in c:php-src
     Use e.g 7-zip to inflate tar.gz or tar.bz

   Or via SVN:
     svn checkout https://svn.php.NET/repository/php/php-src/branches/PHP_5_4
        php-src-5.4

   Unpack the Win32 build extras in the same dir

   Start a Visual Studio 2010 command prompt
     cd php-src
     set PATH=%PATH%;win32buildbin
     set INCLUDE=%INCLUDE%;win32buildinclude
     set LIB=%LIB%;win32buildlib
     buildconf
     configure –disable-zts (and required extensions)
     nmake

   Copy binaries (php-cgi.exe and php5.dll) to your PHP directory
Profile Guided Optimizations
            (PGO)
 Feature of the MS C/C++ compiler (VS Professional or Premium)
 Patch to PHP build environment available here:
   http://www.ksingla.NET/wp-
     content/uploads/2010/05/pgo_build.patch.txt

 Steps
  1. compile PHP with instrumentation enabled --enable-pgi
  2. collect training data (.pgc files)
  3. compile PHP with PGO –with-pgo
 Expected performance improvement: 10-17%
 More details
   http://www.ksingla.NET/2010/05/php-pgo-build-for-maximum-
     performance-on-windows/
Demo
CGI and FastCGI
 CGI (Common Gateway Interface) is the oldest way used to
  generate dynamic content on a web server
   A separate process is spawned for each request (!)
   Request input and response output are handled via standard
    input / output
   Massive overhead due to process handling by the OS
 FastCGI is a variation
   A separate process is spawned but persists among multiple
      requests
     Request input and response output are handled via sockets or
      named pipes
     Processes can be restarted independently
     Good performance
     Very popular in the Apache environment (mod_fastcgid), for
      PHP, Perl, Ruby, etc
IIS FastCGI 1.5
 CGI is slow: every request generates a process instance!

 FastCGI employs the same process for many requests

 Supported on IIS 7.x and IIS 6.0 (the latter via fcgiext.dll
  ISAPI)

 Written in collaboration with Zend (PHP) but is generic

 In IIS 7.x: Enable CGI among the IIS role services

 Note: Install Hotfix KB980363 on IIS 7.0 to get version 1.5!
FastCGI Setup
IIS FastCGI - Versions
Feature                 5.1/6.0   7.0   7.5
Monitoring file         Yes       Yes   Yes
changes
Real-Time max Inst.     Yes       Yes   Yes
tuning
STDERR support          Yes       Yes   Yes
SIGTERM support         Yes       Yes   Yes

Env. variable           Yes       Yes   Yes
_FCGI_X_PIPE_
Proc. Pool per          Yes       Yes   Yes
application
UTF-8 variable          Yes       Yes   No
encoding
IIS CPU Limit support   No        Yes   Yes
FastCGI - PHP
 Install PHP 5.2 or 5.3
    During setup choose FastCGI

 As an alternative, deploy via WebPI

 WP3P.exe
    Loads iisfcgi.dll
    Executes php-cgi.exe
 Config: PHP.INI
    E.g.: fastcgi.impersonate = 1
FastCGI - Settings
Handler Mappings
PHP.INI FastCGI Settings
 fastcgi.impersonate
   supports the ability to impersonate security tokens of the
    calling client
   Default: 1
 fastcgi.logging
   Turns on SAPI logging when using FastCGI
   Default: 1
Web.config - FastCGI
<configuration>
…
 <system.webServer>
  …
  <handlers>
        <clear />
        <add name="PHP53_via_FastCGI" path="*.php"
         verb="GET,HEAD,POST"
         modules="FastCgiModule"
         scriptProcessor="C:Program Files (x86)PHPv5.3php-
cgi.exe"
         resourceType="Either" />
     </handlers>
 </system.webServer>
</configuration>
PHP Manager
 A dedicated tool to support multiple PHP installations
 Features:
   Easy management of the PHP version used by a web app
   Easy management of the PHP parameters
       No direct editing of PHP.INI needed
     Easy management of PHP Extensions
     Best practices
     Quick inspections via phpinfo()
     Easy registration of new PHP installations

 Deployable via WebPI or standalone setup
PHP Manager
Set PHP Limits
PHP Error Reporting
Manage PHP.INI Settings
phpinfo() Output
PHP and FastCGI Performance Optimizations
PHP and FastCGI Performance Optimizations

More Related Content

What's hot

What's hot (20)

RESTful API 설계
RESTful API 설계RESTful API 설계
RESTful API 설계
 
Fastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS AppsFastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS Apps
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
 
Infrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfraInfrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfra
 
ASP.NETからASP.NET Coreに移行した話
ASP.NETからASP.NET Coreに移行した話ASP.NETからASP.NET Coreに移行した話
ASP.NETからASP.NET Coreに移行した話
 
Java 9/10/11 - What's new and why you should upgrade
Java 9/10/11 - What's new and why you should upgradeJava 9/10/11 - What's new and why you should upgrade
Java 9/10/11 - What's new and why you should upgrade
 
RESTful API – How to Consume, Extract, Store and Visualize Data with InfluxDB...
RESTful API – How to Consume, Extract, Store and Visualize Data with InfluxDB...RESTful API – How to Consume, Extract, Store and Visualize Data with InfluxDB...
RESTful API – How to Consume, Extract, Store and Visualize Data with InfluxDB...
 
[오픈소스컨설팅]J boss6 7_교육자료
[오픈소스컨설팅]J boss6 7_교육자료[오픈소스컨설팅]J boss6 7_교육자료
[오픈소스컨설팅]J boss6 7_교육자료
 
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph
 
Gerenciamento de Backup e Recovery com Barman PGConfBrasil2019
Gerenciamento de Backup e Recovery com Barman PGConfBrasil2019Gerenciamento de Backup e Recovery com Barman PGConfBrasil2019
Gerenciamento de Backup e Recovery com Barman PGConfBrasil2019
 
Open vSwitch 패킷 처리 구조
Open vSwitch 패킷 처리 구조Open vSwitch 패킷 처리 구조
Open vSwitch 패킷 처리 구조
 
JBoss EAP / WildFly, State of the Union
JBoss EAP / WildFly, State of the UnionJBoss EAP / WildFly, State of the Union
JBoss EAP / WildFly, State of the Union
 
Cucumber and Spock Primer
Cucumber and Spock PrimerCucumber and Spock Primer
Cucumber and Spock Primer
 
Kubernetes 101
Kubernetes 101Kubernetes 101
Kubernetes 101
 
Upgrade to java 16 or 17
Upgrade to java 16 or 17Upgrade to java 16 or 17
Upgrade to java 16 or 17
 
Implementing Microservices Security Patterns & Protocols with Spring
Implementing Microservices Security Patterns & Protocols with SpringImplementing Microservices Security Patterns & Protocols with Spring
Implementing Microservices Security Patterns & Protocols with Spring
 
RichFaces 4: Rich Ajax Components For Your JSF Applications
RichFaces 4: Rich Ajax Components For Your JSF ApplicationsRichFaces 4: Rich Ajax Components For Your JSF Applications
RichFaces 4: Rich Ajax Components For Your JSF Applications
 
Flutter overview - advantages & disadvantages for business
Flutter overview - advantages & disadvantages for businessFlutter overview - advantages & disadvantages for business
Flutter overview - advantages & disadvantages for business
 
Docker & Kubernetes 기초 - 최용호
Docker & Kubernetes 기초 - 최용호Docker & Kubernetes 기초 - 최용호
Docker & Kubernetes 기초 - 최용호
 
Introduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fastIntroduction to Flutter - truly crossplatform, amazingly fast
Introduction to Flutter - truly crossplatform, amazingly fast
 

Similar to PHP and FastCGI Performance Optimizations

Php Asp Net Interoperability Rc Jao
Php Asp Net Interoperability Rc JaoPhp Asp Net Interoperability Rc Jao
Php Asp Net Interoperability Rc Jao
jedt
 
Windows Loves Drupal
Windows Loves DrupalWindows Loves Drupal
Windows Loves Drupal
Acquia
 

Similar to PHP and FastCGI Performance Optimizations (20)

PHP on Windows 2008
PHP on Windows 2008PHP on Windows 2008
PHP on Windows 2008
 
PHP on Windows - What's New
PHP on Windows - What's NewPHP on Windows - What's New
PHP on Windows - What's New
 
Running PHP on Windows Technical Overview
Running PHP on Windows Technical OverviewRunning PHP on Windows Technical Overview
Running PHP on Windows Technical Overview
 
Wordpress On Windows
Wordpress On WindowsWordpress On Windows
Wordpress On Windows
 
Microsoft, PHP and IIS7
Microsoft, PHP and IIS7Microsoft, PHP and IIS7
Microsoft, PHP and IIS7
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Introduction to YII framework
Introduction to YII frameworkIntroduction to YII framework
Introduction to YII framework
 
Wordpress on Windows
Wordpress on WindowsWordpress on Windows
Wordpress on Windows
 
Php Asp Net Interoperability Rc Jao
Php Asp Net Interoperability Rc JaoPhp Asp Net Interoperability Rc Jao
Php Asp Net Interoperability Rc Jao
 
Windows Loves Drupal
Windows Loves DrupalWindows Loves Drupal
Windows Loves Drupal
 
Automating Your Enterprise Application Deployments with PowerShell
Automating Your Enterprise Application Deployments with PowerShellAutomating Your Enterprise Application Deployments with PowerShell
Automating Your Enterprise Application Deployments with PowerShell
 
Partying with PHP on Microsoft Internet Information Services 7
Partying with PHP on Microsoft Internet Information Services 7Partying with PHP on Microsoft Internet Information Services 7
Partying with PHP on Microsoft Internet Information Services 7
 
Install
InstallInstall
Install
 
Secure PHP environment
Secure PHP environmentSecure PHP environment
Secure PHP environment
 
Continuous integration / continuous delivery
Continuous integration / continuous deliveryContinuous integration / continuous delivery
Continuous integration / continuous delivery
 
Windows Loves drupal
Windows Loves drupalWindows Loves drupal
Windows Loves drupal
 
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...Automating Your Enterprise Application Deployments With PowerShell by Geoff V...
Automating Your Enterprise Application Deployments With PowerShell by Geoff V...
 
Nginx pres
Nginx presNginx pres
Nginx pres
 
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
 
IIS 6.0 and asp.net
IIS 6.0 and asp.netIIS 6.0 and asp.net
IIS 6.0 and asp.net
 

More from Alessandro Pilotti

Interoperable OpenStack guest provisioning with Cloudbase-Init
Interoperable OpenStack guest provisioning with Cloudbase-InitInteroperable OpenStack guest provisioning with Cloudbase-Init
Interoperable OpenStack guest provisioning with Cloudbase-Init
Alessandro Pilotti
 
Hyper-V OpenStack Nova Compute
Hyper-V OpenStack Nova ComputeHyper-V OpenStack Nova Compute
Hyper-V OpenStack Nova Compute
Alessandro Pilotti
 

More from Alessandro Pilotti (14)

OpenStack and Windows - What's new in Ocata
OpenStack and Windows - What's new in OcataOpenStack and Windows - What's new in Ocata
OpenStack and Windows - What's new in Ocata
 
Strategies for migrating workloads from VMware to OpenStack
Strategies for migrating workloads from VMware to OpenStackStrategies for migrating workloads from VMware to OpenStack
Strategies for migrating workloads from VMware to OpenStack
 
Puppet + Windows Nano Server
Puppet + Windows Nano ServerPuppet + Windows Nano Server
Puppet + Windows Nano Server
 
OpenStack + Nano Server + Hyper-V + S2D
OpenStack + Nano Server + Hyper-V + S2DOpenStack + Nano Server + Hyper-V + S2D
OpenStack + Nano Server + Hyper-V + S2D
 
Building a Microsoft cloud with open technologies
Building a Microsoft cloud with open technologiesBuilding a Microsoft cloud with open technologies
Building a Microsoft cloud with open technologies
 
OpenStack Summit 2013 Hong Kong - OpenStack and Windows
OpenStack Summit 2013 Hong Kong - OpenStack and WindowsOpenStack Summit 2013 Hong Kong - OpenStack and Windows
OpenStack Summit 2013 Hong Kong - OpenStack and Windows
 
Interoperable OpenStack guest provisioning with Cloudbase-Init
Interoperable OpenStack guest provisioning with Cloudbase-InitInteroperable OpenStack guest provisioning with Cloudbase-Init
Interoperable OpenStack guest provisioning with Cloudbase-Init
 
OpenStack and Windows
OpenStack and WindowsOpenStack and Windows
OpenStack and Windows
 
An HTML5 client to connect to the Hyper-V console
An HTML5 client to connect to the Hyper-V consoleAn HTML5 client to connect to the Hyper-V console
An HTML5 client to connect to the Hyper-V console
 
Hyper-V OpenStack Nova Compute
Hyper-V OpenStack Nova ComputeHyper-V OpenStack Nova Compute
Hyper-V OpenStack Nova Compute
 
Drupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on WindowsDrupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on Windows
 
Managing Drupal on Windows with Drush
Managing Drupal on Windows with DrushManaging Drupal on Windows with Drush
Managing Drupal on Windows with Drush
 
Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1
 
Building modern web sites with ASP .Net Web API, WebSockets and RSignal
Building modern web sites with ASP .Net Web API, WebSockets and RSignalBuilding modern web sites with ASP .Net Web API, WebSockets and RSignal
Building modern web sites with ASP .Net Web API, WebSockets and RSignal
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

PHP and FastCGI Performance Optimizations

  • 1. PHP + FastCGI Performance Optimizations Alessandro Pilotti Twitter: @alexpilotti MVP ASP.NET / IIS MCSD, MCAD, MCSE, MCDBA, MCT Red Hat Certified Engineer
  • 2. PHP on IIS  FastCGI  Best available option  ISAPI  The way to go before FastCGI  Low reliability due to reentrance problems  DLL loaded at W3SVC instance level  Security issues  CGI (not FastCGI)  Awful performance
  • 3. How to get PHP on Windows  Binaries  http://windows.php.NET/download/  Visual Studio C++ CRT DLL: VC6 or VC9?  Apache: VC6  IIS: VC9  Thread safe or not thread safe?  Thread safe for ISAPI  Non Thread Safe for CGI/FastCGI  Massive performance improvement!  x86 vs x64  Do you need > 4GB of process space?
  • 4. WebPI  Microsoft Web Platform Installer (WebPI) is a free tool that simplifies deployment of web solutions  IIS features and extensions  WinCache, PHP Drivers for SQL Server, PHP Manager  Frameworks  .NET, PHP, etc  Web applications  Drupal, Joomla, Wordpress, DotNetNuke, Orchard, etc  Database  MS SQL Server Express, MySQL, etc  WebMatrix  Both PHP 5.2 and 5.3 can be easily deployed via WebPI  Local cache:  "%localappdata%Microsoftweb platform installer"
  • 9. Compiling PHP  If you want:  A PHP release available in sources  A development build for testing purposes  What do you need:  Sources, e.g.: http://php.NET/downloads.php  Subversion client (e.g. TortoiseSVN)  Instructions:  https://wiki.php.net/internals/windows/stepbystepbuild  PHP build extras  http://windows.php.net/downloads/php-sdk/  Deps and binaries: bison.exe, flex.exe, etc. and additional include and libs  Visual Studio 2008 or 2010  The Express edition (free) is enough
  • 10. Compiling PHP  Unpack the downloaded sources, e.g in c:php-src  Use e.g 7-zip to inflate tar.gz or tar.bz  Or via SVN:  svn checkout https://svn.php.NET/repository/php/php-src/branches/PHP_5_4 php-src-5.4  Unpack the Win32 build extras in the same dir  Start a Visual Studio 2010 command prompt  cd php-src  set PATH=%PATH%;win32buildbin  set INCLUDE=%INCLUDE%;win32buildinclude  set LIB=%LIB%;win32buildlib  buildconf  configure –disable-zts (and required extensions)  nmake  Copy binaries (php-cgi.exe and php5.dll) to your PHP directory
  • 11. Profile Guided Optimizations (PGO)  Feature of the MS C/C++ compiler (VS Professional or Premium)  Patch to PHP build environment available here:  http://www.ksingla.NET/wp- content/uploads/2010/05/pgo_build.patch.txt  Steps 1. compile PHP with instrumentation enabled --enable-pgi 2. collect training data (.pgc files) 3. compile PHP with PGO –with-pgo  Expected performance improvement: 10-17%  More details  http://www.ksingla.NET/2010/05/php-pgo-build-for-maximum- performance-on-windows/
  • 12. Demo
  • 13. CGI and FastCGI  CGI (Common Gateway Interface) is the oldest way used to generate dynamic content on a web server  A separate process is spawned for each request (!)  Request input and response output are handled via standard input / output  Massive overhead due to process handling by the OS  FastCGI is a variation  A separate process is spawned but persists among multiple requests  Request input and response output are handled via sockets or named pipes  Processes can be restarted independently  Good performance  Very popular in the Apache environment (mod_fastcgid), for PHP, Perl, Ruby, etc
  • 14. IIS FastCGI 1.5  CGI is slow: every request generates a process instance!  FastCGI employs the same process for many requests  Supported on IIS 7.x and IIS 6.0 (the latter via fcgiext.dll ISAPI)  Written in collaboration with Zend (PHP) but is generic  In IIS 7.x: Enable CGI among the IIS role services  Note: Install Hotfix KB980363 on IIS 7.0 to get version 1.5!
  • 16. IIS FastCGI - Versions Feature 5.1/6.0 7.0 7.5 Monitoring file Yes Yes Yes changes Real-Time max Inst. Yes Yes Yes tuning STDERR support Yes Yes Yes SIGTERM support Yes Yes Yes Env. variable Yes Yes Yes _FCGI_X_PIPE_ Proc. Pool per Yes Yes Yes application UTF-8 variable Yes Yes No encoding IIS CPU Limit support No Yes Yes
  • 17. FastCGI - PHP  Install PHP 5.2 or 5.3  During setup choose FastCGI  As an alternative, deploy via WebPI  WP3P.exe  Loads iisfcgi.dll  Executes php-cgi.exe  Config: PHP.INI  E.g.: fastcgi.impersonate = 1
  • 20. PHP.INI FastCGI Settings  fastcgi.impersonate  supports the ability to impersonate security tokens of the calling client  Default: 1  fastcgi.logging  Turns on SAPI logging when using FastCGI  Default: 1
  • 21. Web.config - FastCGI <configuration> … <system.webServer> … <handlers> <clear /> <add name="PHP53_via_FastCGI" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:Program Files (x86)PHPv5.3php- cgi.exe" resourceType="Either" /> </handlers> </system.webServer> </configuration>
  • 22. PHP Manager  A dedicated tool to support multiple PHP installations  Features:  Easy management of the PHP version used by a web app  Easy management of the PHP parameters  No direct editing of PHP.INI needed  Easy management of PHP Extensions  Best practices  Quick inspections via phpinfo()  Easy registration of new PHP installations  Deployable via WebPI or standalone setup