Top Banner
PHP Performance on Windows Mark Brown, Ruslan Yakushev Microsoft
28

Php Performance On Windows

May 13, 2015

Download

Technology

ruslany

The slides from the PHP Architect session "PHP Performance on Windows"
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Php Performance On Windows

PHP Performance on Windows

Mark Brown, Ruslan Yakushev

Microsoft

Page 2: Php Performance On Windows

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

Page 3: Php Performance On Windows

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…

Page 4: Php Performance On Windows

CGI FASTCGI

Page 5: Php Performance On Windows

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

Page 6: Php Performance On Windows

CGI vs. FastCGI

Page 7: Php Performance On Windows

CGI vs. FastCGICGI Processes FastCGI processes

Page 8: Php Performance On Windows

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

Page 9: Php Performance On Windows

IIS FastCGI and PHP Setup - automated

• Use the easiest option - Web Platform Installer!

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

Page 10: Php Performance On Windows

Add PHP installer option

Page 11: Php Performance On Windows

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

Page 12: Php Performance On Windows

PHP 5.2 PHP 5.3

Page 13: Php Performance On Windows

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% +)”

Page 14: Php Performance On Windows

WINCACHE

Page 15: Php Performance On Windows

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!

Page 16: Php Performance On Windows

Why use opcode cache?

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

execute more than 100 PHP files!

Page 17: Php Performance On Windows

WinCache in action

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

Page 18: Php Performance On Windows

WinCache and CPU usage

• WinCache significantly reduces CPU load

• Use FastCGImaxInstances setting to load CPU more

• Set maxInstances to 0 to enable auto tuning

Page 19: Php Performance On Windows

WinCache and CPU usage

Increased FastCGI maxInstances from 4 (default) to 10

Page 20: Php Performance On Windows

WinCache 1.1 User Cache API:

• Stores app data in shared memory

• Function by function compatible with APC

Page 21: Php Performance On Windows

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.

Page 23: Php Performance On Windows

WinCache statistics script

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

Page 24: Php Performance On Windows

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

Page 25: Php Performance On Windows

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.

Page 26: Php Performance On Windows

PHP on Windows - Contacts

• Pierre Joye • (PHP Core Developer)

[email protected]– http://twitter.com/PierreJoye

• Kanwaljeet Singla• (IIS and WinCache

Developer)– [email protected]– http://twitter.com/kjsingla– http://blogs.iis.net/ksingla/

• Venkat Raman Don • (IIS and WinCache Tester)

[email protected]– http://blogs.iis.net/donraman

• Mark Brown • (Web Platform)

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

• Ruslan Yakushev • (IIS Program Manager)

[email protected]– http://twitter.com/ruslany– http://ruslany.net/

Page 27: Php Performance On Windows

PHP on Windows - resources

• http://windows.php.net/

• http://php.iis.net/

• php.windows mailing list

• http://forums.iis.net/

Page 28: Php Performance On Windows

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