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

Manual basis sap_r3
Manual basis sap_r3Manual basis sap_r3
Manual basis sap_r3Criszh90
 
2 ways to get total sum of interactive grid column oracle apex ontoor blogs
2 ways to get total sum of interactive grid column oracle apex   ontoor blogs2 ways to get total sum of interactive grid column oracle apex   ontoor blogs
2 ways to get total sum of interactive grid column oracle apex ontoor blogssulimankareem
 
Gentle Introduction to Scala
Gentle Introduction to ScalaGentle Introduction to Scala
Gentle Introduction to ScalaFangda Wang
 
22827361 ab initio-fa-qs
22827361 ab initio-fa-qs22827361 ab initio-fa-qs
22827361 ab initio-fa-qsCapgemini
 
오픈소스 GIS 실습 (1)
오픈소스 GIS 실습 (1)오픈소스 GIS 실습 (1)
오픈소스 GIS 실습 (1)Byeong-Hyeok Yu
 
GeoServer 2.4.x 한국어 사용자 지침서
GeoServer 2.4.x 한국어 사용자 지침서GeoServer 2.4.x 한국어 사용자 지침서
GeoServer 2.4.x 한국어 사용자 지침서SANGHEE SHIN
 
第一次用 Vue.js 就愛上 [改]
第一次用 Vue.js 就愛上 [改]第一次用 Vue.js 就愛上 [改]
第一次用 Vue.js 就愛上 [改]Kuro Hsu
 
공간정보아카데미 - Day1 오픈소스개발 일반
공간정보아카데미 - Day1 오픈소스개발 일반공간정보아카데미 - Day1 오픈소스개발 일반
공간정보아카데미 - Day1 오픈소스개발 일반BJ Jang
 
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기Heejong Ahn
 
Apex behind the scenes
Apex behind the scenesApex behind the scenes
Apex behind the scenesEnkitec
 
소프트웨어 공학 (최종 설계 명세서)
소프트웨어 공학 (최종 설계 명세서)소프트웨어 공학 (최종 설계 명세서)
소프트웨어 공학 (최종 설계 명세서)Yu Yongwoo
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented ProgrammingScott Wlaschin
 
Composer 從入門到實戰
Composer 從入門到實戰Composer 從入門到實戰
Composer 從入門到實戰Shengyou Fan
 
공간SQL을 이용한 공간자료분석 기초실습
공간SQL을 이용한 공간자료분석 기초실습공간SQL을 이용한 공간자료분석 기초실습
공간SQL을 이용한 공간자료분석 기초실습BJ Jang
 
Writing php extensions in golang
Writing php extensions in golangWriting php extensions in golang
Writing php extensions in golangdo_aki
 
Odoo - Create themes for website
Odoo - Create themes for websiteOdoo - Create themes for website
Odoo - Create themes for websiteOdoo
 

What's hot (20)

Manual basis sap_r3
Manual basis sap_r3Manual basis sap_r3
Manual basis sap_r3
 
2 ways to get total sum of interactive grid column oracle apex ontoor blogs
2 ways to get total sum of interactive grid column oracle apex   ontoor blogs2 ways to get total sum of interactive grid column oracle apex   ontoor blogs
2 ways to get total sum of interactive grid column oracle apex ontoor blogs
 
QGIS 활용
QGIS 활용QGIS 활용
QGIS 활용
 
Gentle Introduction to Scala
Gentle Introduction to ScalaGentle Introduction to Scala
Gentle Introduction to Scala
 
22827361 ab initio-fa-qs
22827361 ab initio-fa-qs22827361 ab initio-fa-qs
22827361 ab initio-fa-qs
 
오픈소스 GIS 실습 (1)
오픈소스 GIS 실습 (1)오픈소스 GIS 실습 (1)
오픈소스 GIS 실습 (1)
 
Optional in Java 8
Optional in Java 8Optional in Java 8
Optional in Java 8
 
GeoServer 2.4.x 한국어 사용자 지침서
GeoServer 2.4.x 한국어 사용자 지침서GeoServer 2.4.x 한국어 사용자 지침서
GeoServer 2.4.x 한국어 사용자 지침서
 
第一次用 Vue.js 就愛上 [改]
第一次用 Vue.js 就愛上 [改]第一次用 Vue.js 就愛上 [改]
第一次用 Vue.js 就愛上 [改]
 
P4 perforce
P4 perforceP4 perforce
P4 perforce
 
공간정보아카데미 - Day1 오픈소스개발 일반
공간정보아카데미 - Day1 오픈소스개발 일반공간정보아카데미 - Day1 오픈소스개발 일반
공간정보아카데미 - Day1 오픈소스개발 일반
 
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
TypeScript와 Flow: 
자바스크립트 개발에 정적 타이핑 도입하기
 
Apex behind the scenes
Apex behind the scenesApex behind the scenes
Apex behind the scenes
 
소프트웨어 공학 (최종 설계 명세서)
소프트웨어 공학 (최종 설계 명세서)소프트웨어 공학 (최종 설계 명세서)
소프트웨어 공학 (최종 설계 명세서)
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented Programming
 
Introduction to Imagine
Introduction to ImagineIntroduction to Imagine
Introduction to Imagine
 
Composer 從入門到實戰
Composer 從入門到實戰Composer 從入門到實戰
Composer 從入門到實戰
 
공간SQL을 이용한 공간자료분석 기초실습
공간SQL을 이용한 공간자료분석 기초실습공간SQL을 이용한 공간자료분석 기초실습
공간SQL을 이용한 공간자료분석 기초실습
 
Writing php extensions in golang
Writing php extensions in golangWriting php extensions in golang
Writing php extensions in golang
 
Odoo - Create themes for website
Odoo - Create themes for websiteOdoo - Create themes for website
Odoo - Create themes for website
 

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

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
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
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
#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
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 

Recently uploaded (20)

Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
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
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
#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
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
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...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 

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