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

Odoo Implementation Methodology
Odoo Implementation MethodologyOdoo Implementation Methodology
Odoo Implementation MethodologyQuang Ngoc
 
Importance of Solution Architecture in Automation
Importance of Solution Architecture in AutomationImportance of Solution Architecture in Automation
Importance of Solution Architecture in AutomationCristina Vidu
 
05. 마이크로서비스 아키텍처 환경에서의 SSO 구축방안
05. 마이크로서비스 아키텍처 환경에서의 SSO 구축방안05. 마이크로서비스 아키텍처 환경에서의 SSO 구축방안
05. 마이크로서비스 아키텍처 환경에서의 SSO 구축방안Opennaru, inc.
 
Latest Trends in Mobile App Development
Latest Trends in Mobile App DevelopmentLatest Trends in Mobile App Development
Latest Trends in Mobile App DevelopmentDipesh Mukerji
 
Washington DC MuleSoft Meetup: CI/CD Pipeline with MuleSoft and Azure DevOps
Washington DC MuleSoft Meetup: CI/CD Pipeline with MuleSoft and Azure DevOpsWashington DC MuleSoft Meetup: CI/CD Pipeline with MuleSoft and Azure DevOps
Washington DC MuleSoft Meetup: CI/CD Pipeline with MuleSoft and Azure DevOpsBig Compass
 
Pyshark in Network Packet analysis
Pyshark in Network Packet analysisPyshark in Network Packet analysis
Pyshark in Network Packet analysisRengaraj D
 
UiPath Excel Automation | UiPath Excel Activities | UiPath Training Essential...
UiPath Excel Automation | UiPath Excel Activities | UiPath Training Essential...UiPath Excel Automation | UiPath Excel Activities | UiPath Training Essential...
UiPath Excel Automation | UiPath Excel Activities | UiPath Training Essential...Edureka!
 
Introduction to Robotic Process Automation (rpa) and RPA Case Study
Introduction to Robotic Process Automation (rpa) and RPA Case StudyIntroduction to Robotic Process Automation (rpa) and RPA Case Study
Introduction to Robotic Process Automation (rpa) and RPA Case StudyALTEN Calsoft Labs
 
Introduction To UiPath Studio | Edureka
Introduction To UiPath Studio | EdurekaIntroduction To UiPath Studio | Edureka
Introduction To UiPath Studio | EdurekaEdureka!
 
What's new in API Connect and DataPower - 2019
What's new in API Connect and DataPower - 2019What's new in API Connect and DataPower - 2019
What's new in API Connect and DataPower - 2019IBM DataPower Gateway
 
Odoo Partnership Program
Odoo Partnership ProgramOdoo Partnership Program
Odoo Partnership ProgramOdoo
 
Software defined vehicles,automotive standards (safety, security), agile cont...
Software defined vehicles,automotive standards (safety, security), agile cont...Software defined vehicles,automotive standards (safety, security), agile cont...
Software defined vehicles,automotive standards (safety, security), agile cont...Dr. Anish Cheriyan (PhD)
 
Automotive embedded systems part6 v2
Automotive embedded systems part6 v2Automotive embedded systems part6 v2
Automotive embedded systems part6 v2Keroles karam khalil
 
The Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventureThe Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventuremylittleadventure
 
Familiarization with UiPath Studio.pptx
Familiarization with UiPath Studio.pptxFamiliarization with UiPath Studio.pptx
Familiarization with UiPath Studio.pptxApurbaSamanta9
 
Towards Computer-Aided, Iterative TSN-and Ethernet-based E/E Architecture Design
Towards Computer-Aided, Iterative TSN-and Ethernet-based E/E Architecture DesignTowards Computer-Aided, Iterative TSN-and Ethernet-based E/E Architecture Design
Towards Computer-Aided, Iterative TSN-and Ethernet-based E/E Architecture DesignRealTime-at-Work (RTaW)
 
Robotic Process Automation with UiPath Studio
Robotic Process Automation with UiPath StudioRobotic Process Automation with UiPath Studio
Robotic Process Automation with UiPath StudioLalit Birla
 

What's hot (20)

Odoo Implementation Methodology
Odoo Implementation MethodologyOdoo Implementation Methodology
Odoo Implementation Methodology
 
Importance of Solution Architecture in Automation
Importance of Solution Architecture in AutomationImportance of Solution Architecture in Automation
Importance of Solution Architecture in Automation
 
05. 마이크로서비스 아키텍처 환경에서의 SSO 구축방안
05. 마이크로서비스 아키텍처 환경에서의 SSO 구축방안05. 마이크로서비스 아키텍처 환경에서의 SSO 구축방안
05. 마이크로서비스 아키텍처 환경에서의 SSO 구축방안
 
Api presentation
Api presentationApi presentation
Api presentation
 
Latest Trends in Mobile App Development
Latest Trends in Mobile App DevelopmentLatest Trends in Mobile App Development
Latest Trends in Mobile App Development
 
Washington DC MuleSoft Meetup: CI/CD Pipeline with MuleSoft and Azure DevOps
Washington DC MuleSoft Meetup: CI/CD Pipeline with MuleSoft and Azure DevOpsWashington DC MuleSoft Meetup: CI/CD Pipeline with MuleSoft and Azure DevOps
Washington DC MuleSoft Meetup: CI/CD Pipeline with MuleSoft and Azure DevOps
 
Pyshark in Network Packet analysis
Pyshark in Network Packet analysisPyshark in Network Packet analysis
Pyshark in Network Packet analysis
 
UiPath Excel Automation | UiPath Excel Activities | UiPath Training Essential...
UiPath Excel Automation | UiPath Excel Activities | UiPath Training Essential...UiPath Excel Automation | UiPath Excel Activities | UiPath Training Essential...
UiPath Excel Automation | UiPath Excel Activities | UiPath Training Essential...
 
Introduction to Robotic Process Automation (rpa) and RPA Case Study
Introduction to Robotic Process Automation (rpa) and RPA Case StudyIntroduction to Robotic Process Automation (rpa) and RPA Case Study
Introduction to Robotic Process Automation (rpa) and RPA Case Study
 
Introduction To UiPath Studio | Edureka
Introduction To UiPath Studio | EdurekaIntroduction To UiPath Studio | Edureka
Introduction To UiPath Studio | Edureka
 
What's new in API Connect and DataPower - 2019
What's new in API Connect and DataPower - 2019What's new in API Connect and DataPower - 2019
What's new in API Connect and DataPower - 2019
 
Odoo Partnership Program
Odoo Partnership ProgramOdoo Partnership Program
Odoo Partnership Program
 
Google Maps
Google MapsGoogle Maps
Google Maps
 
Software defined vehicles,automotive standards (safety, security), agile cont...
Software defined vehicles,automotive standards (safety, security), agile cont...Software defined vehicles,automotive standards (safety, security), agile cont...
Software defined vehicles,automotive standards (safety, security), agile cont...
 
Automotive embedded systems part6 v2
Automotive embedded systems part6 v2Automotive embedded systems part6 v2
Automotive embedded systems part6 v2
 
System Platform
System PlatformSystem Platform
System Platform
 
The Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventureThe Go programming language - Intro by MyLittleAdventure
The Go programming language - Intro by MyLittleAdventure
 
Familiarization with UiPath Studio.pptx
Familiarization with UiPath Studio.pptxFamiliarization with UiPath Studio.pptx
Familiarization with UiPath Studio.pptx
 
Towards Computer-Aided, Iterative TSN-and Ethernet-based E/E Architecture Design
Towards Computer-Aided, Iterative TSN-and Ethernet-based E/E Architecture DesignTowards Computer-Aided, Iterative TSN-and Ethernet-based E/E Architecture Design
Towards Computer-Aided, Iterative TSN-and Ethernet-based E/E Architecture Design
 
Robotic Process Automation with UiPath Studio
Robotic Process Automation with UiPath StudioRobotic Process Automation with UiPath Studio
Robotic Process Automation with UiPath Studio
 

Similar to PHP and FastCGI Performance Optimizations

PHP on Windows 2008
PHP on Windows 2008PHP on Windows 2008
PHP on Windows 2008jorke
 
PHP on Windows - What's New
PHP on Windows - What's NewPHP on Windows - What's New
PHP on Windows - What's NewZendCon
 
Running PHP on Windows Technical Overview
Running PHP on Windows Technical OverviewRunning PHP on Windows Technical Overview
Running PHP on Windows Technical OverviewWes Yanaga
 
Wordpress On Windows
Wordpress On WindowsWordpress On Windows
Wordpress On WindowsJosh Holmes
 
Microsoft, PHP and IIS7
Microsoft, PHP and IIS7Microsoft, PHP and IIS7
Microsoft, PHP and IIS7Nick Hodge
 
Introduction to YII framework
Introduction to YII frameworkIntroduction to YII framework
Introduction to YII frameworkNaincy Gupta
 
Wordpress on Windows
Wordpress on WindowsWordpress on Windows
Wordpress on WindowsJosh Holmes
 
Php Asp Net Interoperability Rc Jao
Php Asp Net Interoperability Rc JaoPhp Asp Net Interoperability Rc Jao
Php Asp Net Interoperability Rc Jaojedt
 
Windows Loves Drupal
Windows Loves DrupalWindows Loves Drupal
Windows Loves DrupalAcquia
 
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 PowerShellGeoff Varosky
 
Php Performance On Windows
Php Performance On WindowsPhp Performance On Windows
Php Performance On Windowsruslany
 
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 7goodfriday
 
Continuous integration / continuous delivery
Continuous integration / continuous deliveryContinuous integration / continuous delivery
Continuous integration / continuous deliveryEatDog
 
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...SPTechCon
 
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...Evgeniy Kuzmin
 

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
 
Php Performance On Windows
Php Performance On WindowsPhp Performance On Windows
Php Performance On Windows
 
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...
 

More from Alessandro Pilotti

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 OcataAlessandro Pilotti
 
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 OpenStackAlessandro Pilotti
 
OpenStack + Nano Server + Hyper-V + S2D
OpenStack + Nano Server + Hyper-V + S2DOpenStack + Nano Server + Hyper-V + S2D
OpenStack + Nano Server + Hyper-V + S2DAlessandro Pilotti
 
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 technologiesAlessandro Pilotti
 
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 WindowsAlessandro 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-InitAlessandro Pilotti
 
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 consoleAlessandro Pilotti
 
Hyper-V OpenStack Nova Compute
Hyper-V OpenStack Nova ComputeHyper-V OpenStack Nova Compute
Hyper-V OpenStack Nova ComputeAlessandro Pilotti
 
Drupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on WindowsDrupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on WindowsAlessandro Pilotti
 
Managing Drupal on Windows with Drush
Managing Drupal on Windows with DrushManaging Drupal on Windows with Drush
Managing Drupal on Windows with DrushAlessandro Pilotti
 
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 1Alessandro Pilotti
 
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 RSignalAlessandro 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

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Recently uploaded (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

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