Php Performance On Windows

Post on 13-May-2015

21.469 views 3 download

Tags:

description

The slides from the PHP Architect session "PHP Performance on Windows"

Transcript of Php Performance On Windows

PHP Performance on Windows

Mark Brown, Ruslan Yakushev

Microsoft

A Little History

• PHP on Win/IIS = Big Joke2006

• IIS FastCGI2007• windows.php.net

• PHP 5.32008• PHP 5.3 Release

• WinCache 1.02009• FastCGI 1.5

• WinCache 1.12010

PHP Community and Microsoft

• “PHP on Windows” project involves:

– PHP core developers

– PHP installer developers

– PHP documentation team

– PHP community and influentials

– PHP applications communities (WordPress, Joomla, Drupal, others)

– Many others…

CGI FASTCGI

CGI vs FastCGI

• (CGI on Windows) == SLOW !!!– New PHP process per request

• FastCGI == (CGI on steroids)– Re-use PHP processes in a process pool

– Single-threaded execution environment

– Use Non-Thread Safe PHP with IIS FastCGI

• PHP ISAPI?– Stay away!!! Use FastCGI instead

– No ISAPI support in 5.3 anyway

CGI vs. FastCGI

CGI vs. FastCGICGI Processes FastCGI processes

FastCGI 1.5

• New features:– Auto-tuning of maxIntances for optimal performance

– Automatic recycling of PHP processes with configchange MonitorChangesTo setting

– No more restarts with changes to php.ini

• Consistent set of features across all IIS versions:– For IIS 7.5 in WS08 R2 – new features are included

– For IIS 7.0 in WS08 – install the FastCGI update (http://www.iis.net/expand/FastCGI)

– For IIS 5.1 & 6.0 – install FastCGI 1.5 extension

IIS FastCGI and PHP Setup - automated

• Use the easiest option - Web Platform Installer!

Get Web Platform Installer from http://www.microsoft.com/web/php/

Add PHP installer option

IIS FastCGI & PHP Setup - manual

• Follow the instructions on php.net:

• IIS 5.1 and IIS 6.0:– php.net/manual/en/install.windows.iis6.php

• IIS 7 and later:– php.net/manual/en/install.windows.iis7.php

• PHP configuration– php.net/manual/en/install.windows.manual.php

PHP 5.2 PHP 5.3

PHP 5.3 improvements

• PHP 5.3 improvements:

– Using VC9 compiler (PHP 5.2 used VC6)

– Optimized API calls (using Win32 instead of POSIX)

– All PHP libraries built from the source code

– Compatibility fixes

• Windows builds are available at:

– http://windows.php.net/

From: http://ilia.ws/files/Confoo2010_PHP53.pdf“Substantial performance improvements on Windows (40% +)”

WINCACHE

WinCache 1.0

• PHP Accelerator optimized for Windows– Opcode cache– File cache– Resolve path cache

• Download from:– http://www.iis.net/expand/WinCacheForPhp

• Contributed by MS to PECL:– Source code on http://pecl.php.net/wincache/– Documentation on http://www.php.net/wincache/– BSD license

Contributions are welcome!

Why use opcode cache?

To serve an index.php in WordPress, PHP has to read, parse, compile and

execute more than 100 PHP files!

WinCache in action

Just add extension=php_wincache.dll in php.ini. No app code changes necessary!

WinCache and CPU usage

• WinCache significantly reduces CPU load

• Use FastCGImaxInstances setting to load CPU more

• Set maxInstances to 0 to enable auto tuning

WinCache and CPU usage

Increased FastCGI maxInstances from 4 (default) to 10

WinCache 1.1 User Cache API:

• Stores app data in shared memory

• Function by function compatible with APC

WinCache 1.1 – Session Handler

• Stores PHP session data in shared memory

• Enabled in php.ini :session.save_handler = wincache

• Session storage is not persistent in beta, but will be in RC:

– Use the code snapshot to try it out.

WinCache statistics script

Always restrict access to wincache.php by using built-in authentication or web server authentication!

What’s next?

• Popular PHP applications to adopt WinCache:

– Joomla 1.6

– Drupal cacherouter module

– Sugar CRM

• WinCache improvements:

– File change notifications support

– Function hooks

Summary

• In 3 years Windows/IIS has become a great option for hosting PHP applications

• In 2 years the PHP performance on Windows has improved considerably.

PHP on Windows - Contacts

• Pierre Joye • (PHP Core Developer)

– pajoye@php.net– http://twitter.com/PierreJoye

• Kanwaljeet Singla• (IIS and WinCache

Developer)– ksingla@microsoft.com– http://twitter.com/kjsingla– http://blogs.iis.net/ksingla/

• Venkat Raman Don • (IIS and WinCache Tester)

– donraman@microsoft.com– http://blogs.iis.net/donraman

• Mark Brown • (Web Platform)

– twitter.com/markjbrown– blogs.msdn.com/markbrown/

• Ruslan Yakushev • (IIS Program Manager)

– ruslany@microsoft.com– http://twitter.com/ruslany– http://ruslany.net/

PHP on Windows - resources

• http://windows.php.net/

• http://php.iis.net/

• php.windows mailing list

• http://forums.iis.net/

Test setup

• Quad core CPU + 4 GB RAM

• Windows Server 2008 with IIS 7.0 and FastCGI

• PHP 5.3.2

• WinCache 1.1 beta

• WordPress 2.9.2

• + Load Generator and MySQL on the same box