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

Electron - Build cross platform desktop apps
Electron - Build cross platform desktop appsElectron - Build cross platform desktop apps
Electron - Build cross platform desktop appsPriyaranjan Mohanty
 
Colorful world-of-visual-automation-testing-latest
Colorful world-of-visual-automation-testing-latestColorful world-of-visual-automation-testing-latest
Colorful world-of-visual-automation-testing-latestOnur Baskirt
 
Uwpアプリケーション開発入門
Uwpアプリケーション開発入門Uwpアプリケーション開発入門
Uwpアプリケーション開発入門Makoto Nishimura
 
발표자료 1인qa로살아남는6가지방법
발표자료 1인qa로살아남는6가지방법발표자료 1인qa로살아남는6가지방법
발표자료 1인qa로살아남는6가지방법SangIn Choung
 
Modern Web Development
Modern Web DevelopmentModern Web Development
Modern Web DevelopmentRobert Nyman
 
Janus + Audio @ Open Source World
Janus + Audio @ Open Source WorldJanus + Audio @ Open Source World
Janus + Audio @ Open Source WorldLorenzo Miniero
 
[2018] 프런트엔드 성능 최적화
[2018] 프런트엔드 성능 최적화[2018] 프런트엔드 성능 최적화
[2018] 프런트엔드 성능 최적화NHN FORWARD
 
Introduction to Robot Framework – Exove
Introduction to Robot Framework – ExoveIntroduction to Robot Framework – Exove
Introduction to Robot Framework – ExoveExove
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD123abcda
 
Advantages And Disadvantages Of Joomla
Advantages And Disadvantages Of JoomlaAdvantages And Disadvantages Of Joomla
Advantages And Disadvantages Of Joomlatradocaj
 
(애자일) 테스트 계획서 샘플
(애자일) 테스트 계획서 샘플(애자일) 테스트 계획서 샘플
(애자일) 테스트 계획서 샘플SangIn Choung
 
The Many Ways to Test Your React App
The Many Ways to Test Your React AppThe Many Ways to Test Your React App
The Many Ways to Test Your React AppAll Things Open
 
[140315 박민근] 젠킨스를 이용한 자동빌드 시스템 구축하기(ci)
[140315 박민근] 젠킨스를 이용한 자동빌드 시스템 구축하기(ci)[140315 박민근] 젠킨스를 이용한 자동빌드 시스템 구축하기(ci)
[140315 박민근] 젠킨스를 이용한 자동빌드 시스템 구축하기(ci)MinGeun Park
 
Mobile Browser Internal (Blink Rendering Engine)
Mobile Browser Internal (Blink Rendering Engine)Mobile Browser Internal (Blink Rendering Engine)
Mobile Browser Internal (Blink Rendering Engine)Hyungwook Lee
 
Selenoid: browsers in containers
Selenoid: browsers in containersSelenoid: browsers in containers
Selenoid: browsers in containersIvan Krutov
 
Single page application
Single page applicationSingle page application
Single page applicationArthur Fung
 

What's hot (20)

Electron - Build cross platform desktop apps
Electron - Build cross platform desktop appsElectron - Build cross platform desktop apps
Electron - Build cross platform desktop apps
 
Jenkins-CI
Jenkins-CIJenkins-CI
Jenkins-CI
 
Colorful world-of-visual-automation-testing-latest
Colorful world-of-visual-automation-testing-latestColorful world-of-visual-automation-testing-latest
Colorful world-of-visual-automation-testing-latest
 
Uwpアプリケーション開発入門
Uwpアプリケーション開発入門Uwpアプリケーション開発入門
Uwpアプリケーション開発入門
 
발표자료 1인qa로살아남는6가지방법
발표자료 1인qa로살아남는6가지방법발표자료 1인qa로살아남는6가지방법
발표자료 1인qa로살아남는6가지방법
 
Modern Web Development
Modern Web DevelopmentModern Web Development
Modern Web Development
 
Janus + Audio @ Open Source World
Janus + Audio @ Open Source WorldJanus + Audio @ Open Source World
Janus + Audio @ Open Source World
 
[2018] 프런트엔드 성능 최적화
[2018] 프런트엔드 성능 최적화[2018] 프런트엔드 성능 최적화
[2018] 프런트엔드 성능 최적화
 
Test Complete
Test CompleteTest Complete
Test Complete
 
Introduction to Robot Framework – Exove
Introduction to Robot Framework – ExoveIntroduction to Robot Framework – Exove
Introduction to Robot Framework – Exove
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD
 
Advantages And Disadvantages Of Joomla
Advantages And Disadvantages Of JoomlaAdvantages And Disadvantages Of Joomla
Advantages And Disadvantages Of Joomla
 
(애자일) 테스트 계획서 샘플
(애자일) 테스트 계획서 샘플(애자일) 테스트 계획서 샘플
(애자일) 테스트 계획서 샘플
 
The Many Ways to Test Your React App
The Many Ways to Test Your React AppThe Many Ways to Test Your React App
The Many Ways to Test Your React App
 
[140315 박민근] 젠킨스를 이용한 자동빌드 시스템 구축하기(ci)
[140315 박민근] 젠킨스를 이용한 자동빌드 시스템 구축하기(ci)[140315 박민근] 젠킨스를 이용한 자동빌드 시스템 구축하기(ci)
[140315 박민근] 젠킨스를 이용한 자동빌드 시스템 구축하기(ci)
 
Mobile Browser Internal (Blink Rendering Engine)
Mobile Browser Internal (Blink Rendering Engine)Mobile Browser Internal (Blink Rendering Engine)
Mobile Browser Internal (Blink Rendering Engine)
 
Selenoid: browsers in containers
Selenoid: browsers in containersSelenoid: browsers in containers
Selenoid: browsers in containers
 
Swoole Love PHP
Swoole Love PHPSwoole Love PHP
Swoole Love PHP
 
Single page application
Single page applicationSingle page application
Single page application
 
Git flow
Git flowGit flow
Git flow
 

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
 
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
 
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

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

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
🐬 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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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 educationjfdjdjcjdnsjd
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Recently uploaded (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

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