How to get the most with Windows and Windows Azure
1. How to get the most with Windows and Windows Azure Kanwaljeet Singla & Sumit Chawla Microsoft Corporation
2. Agenda PHP on Windows How to make PHP fly on IIS SQL Server Driver for PHP Web Platform Installer Community PHP on Windows Azure What is the Microsoft Cloud? Deploying a PHP application to the cloud Windows Azure SDKs and Tools for PHP Questions / Open Discussion
3. FastCGI Fast and Reliable. v1.0 released in Oct 2007 v1.5 released in Nov 2009 Consistent set of features across all IIS versions: FastCGI in IIS 7.5 – new features included in OS FastCGI in IIS 7.0 – install the FastCGI update (http://www.iis.net/expand/FastCGI) FastCGI in IIS 5.1/IIS 6.0 – install FastCGI 1.5 extension Recommended way of running PHP on Windows
4. FastCGI (cont.) New features: Auto-tuning of maxInstances Automatic recycling of PHP processes when php.ini changes Useful tips Use latest version of FastCGI and turn on dynamic maxInstances and monitorChangesTo features Increase InstanceMaxRequests value and match the value to PHP_FCGI_MAX_REQUESTS environment variable
5. PHP 5.3 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% +)”
6. 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!
7. Why use opcode cache? To serve index.php in WordPress, PHP has to read, parse, compileand execute more than 100 php files!
8. WinCache 1.0 Useful Tips: Increase maxInstances or use dynamic maxInstances Adjust file cache and opcode cache sizes. Use wincache.php to study cache usage Keep wincache.chkinterval value high on production servers and low on development machines Restrict access to wincache.php by using built-inauthentication or web server authentication
9. WinCache 1.1 Beta2 released in April 2010 Object cache – Compatible with APC APIs WinCache session handler File change notification support Function hooks Useful Tips: Turn on user cache if application supports it Port from existing code which uses APC’s object cache Keep file change notification turned on Turn on session handler if not running a web farm
10. SQL Server Driver for PHP Thin layer over SNAC (ODBC) Single functional layer with thin API layer on top SQL Server Driver for PHP 1.1 SQL Server Driver for PHP 2.0 php_sqlsrv.dll php_pdo_sqlsrv.dll php_sqlsrv.dll PDO API SQLSRV Native API SQLSRV Native API Core Functional Layer SQL Server Native Client (ODBC)
11. SQL Server Driver for PHP Tips Scrollable Cursor: scrollable but slower Use sqlsrv_has_rows() w/ CURSOR_FORWARD if you only need to check if there’s data in the resultset, it’s faster and doesn’t move the cursor If scrollable required, consider CURSOR_STATIC first WarningsReturnAsErrors: ON by default Remember to turn it OFF in deployment Should we change default to OFF? UTF-8 encoding The default for PDO, available per col/param Should we make this the default for sqlsrv_xxx? Use transactions for DDL to improve performance
12. SQL Server Query Tips Range query: SELECT * FROM table ORDER BY date LIMIT 20,10 Use TOP & ROW_NUMBER SELECT sub2.*,ROW_NUMBER() OVER(ORDER BY sub2._l2) AS _lFROM ( SELECT 1 AS _l2, sub1.* FROM ( SELECT TOP(30) * FROM table ORDER BY date ) AS sub1) as sub2WHERE _l BETWEEN 20 AND 30; SELECT * FROM ( SELECT *, ROW_NUMBER() OVER(ORDER BY date) AS _l FROM table ) AS t WHERE _l BETWEEN 20 AND 30 ORDER BY _l;
13. Web Platform Installer Easy way to install IIS components, PHP 5.2, PHP and Asp.Net web applications etc. Demo PHP 5.3 will be offered through WebPI soon
14. Community participation WinCache is on PECL and SQL driver for PHP is on codeplex IIS and WinCache documentation on php.net Participating on PHP newsgroups Working with PHP developers to improve PHP and PHP installer Working with PHP application developers to integrate URLRewrite, WinCache
15. Miscellaneous tips Set IP address of MySql machine in hosts file Build PHP yourself and statically link WinCache Compile and optimize using PGO for maximum performance URLRewrite Includes htaccess importer Use IIS warm-up module to fill opcode cache before first request arrives
16. What is Windows Azure? It’s an Operating System In the Cloud. Simple Answer? Windows Azure: operating system as an online serviceMicrosoft SQL Azure: fully relational cloud database solutionWindows Azure platform AppFabric: connects cloud services and on-premises applicationsMicrosoft Codename “Dallas”: information marketplace for data and web services
17. Microsoft Data Centers Vision Go Inside Energy Efficient Containers North American Data Centers European Data Centers Asian Data Centers Dublin Chicago Washington Amsterdam San Antonio Hong Kong Singapore
18. The Windows Azure Model http://www.microsoft.com/windowsazure/windowsazure
19. Windows Azure RolesThis is how your code runs in the cloud Worker Role Web Role Public Internet Public Internet [1..n] Web Role Worker Role [1..m] Load Balancer Load balanced Web Farm IIS7 web server Serves HTTP/HTTPS requests No inbound connections by default Typically used to process background tasks by reading requests from storage queue Storage Services Storage Service
20. SQL AzureRelational Database in the cloud Based on SQL Server technologies Scale databases up or down based on business needs No need to install or patch software or other physical administration Automatic high availability and fault tolerance Simple provisioning and deployment of multiple databases http://www.microsoft.com/windowsazure/sqlazure
21.
22. If you do, you are using Windows Azure only as an infrastructure service
23. This means you are responsible for managing the infrastructureSolutions MySQL PHP Web App Hosted Web Core Worker Role [1 VM Instance] http://code.msdn.microsoft.com/hwcworker MySQL Solution Accelerator [>=2 VM Instances] http://code.msdn.microsoft.com/winazuremysqlphp http://microsoftpdc.com/Sessions/SVC51 http://live.visitmix.com/MIX10/Sessions/SVC12
24. Deploying PHP Apps to Windows Azure PHP Application PHP Core Windows Azure Deployment Package (cspkg + configuration) PHP Extensions Windows Azure Command-line Tool for PHP http://azurephptools.codeplex.com/ Download at
25. Windows Azure Command-line Tool for PHP Create new applications or convert existing PHP applications to Windows Azure applications Deploy to Local Development Fabric or the Windows Azure Cloud No IDE required http://azurephptools.codeplex.com/ Download at
27. Windows Azure Command-line Tool for PHP What’s new Worker Role Support Ability to attach an external drive to your Windows Azure Instance [aka X-Drive] http://azurephptools.codeplex.com/ Download at
28. Browser Web Role 1 2 3 LB Queue 7 4 6 5 Worker Role Blob Store Running background tasks with PHP on Windows Azurehttp://phpworkerdemo.cloudapp.net/
29. Other Windows Azure SDKs and ToolsWindows Azure SDK for PHP Overview Enables PHP developers to take advantage of the Microsoft Cloud Services Platform – Windows Azure. Features PHP classes for Windows Azure Blobs, Tables & Queues (for CRUD operations) Helper Classes for HTTP transport, AuhN/AuthZ, REST & Error Management Manageability, Instrumentation & Logging support Also Distributed via Zend Framework Project Site http://www.codeplex.com/PHPAzure Logical architecture Your PHP application XML REST Compute Storage Manage Deployment scenarios PHP Runtime Any internet connected Server PHP Runtime REST REST
30. Other Windows Azure SDKS and Tools Windows Azure Eclipse Tools + Fast CGI + Eclipse IDE + PHP SDK for Windows Azure 1 2 4 3
31. Summary Recap PHP on Windows has come a long way in the last few years We are committed to improving the PHP experience on Windows Windows Azure Platform offers scalable operating system as service and relational database services in the cloud Windows Azure is more than a hosting infrastructure There are several SDKs and Tools available for developing and deploying PHP Apps to the Microsoft Cloud Call to Action What scenarios are important to you? What would make Windows Azure more interesting for you?
32. Additional Resources PHP on Windows http://windows.php.net/ http://php.iis.net/ http://www.microsoft.com/web/php/ http://forums.iis.net/ http://www.ksingla.net php.windows mailing list PHP Interoperability http://www.interoperabilitybridges.com http://www.azure.com/interoperability http://blogs.msdn.com/interoperability
33. Contact Information PHP on Windows PHP Interoperability Kanwaljeet Singla (IIS and WinCache Developer) ksingla@microsoft.com http://twitter.com/kjsingla http://blogs.iis.net/ksingla/ Ruslan Yakushev (IIS Program Manager) ruslany@microsoft.com http://twitter.com/ruslany http://ruslany.net/ Venkat Raman Don (IIS and WinCache Tester) donraman@microsoft.com http://blogs.iis.net/donraman Pierre Joye (PHP Core Developer) pajoye@php.net http://twitter.com/PierreJoye Mark Brown (IIS Product Manager) http://twitter.com/markjbrown http://blogs.msdn.com/markbrown/ Sumit Chawla sumit.chawla@microsoft.com Jean-Christophe jccim@microsoft.com Vijay Rajagopalan vijayr@microsoft.com Karri Dunn Karri.dunn@microsoft.com Jas Sandhu Jassand@microsoft.co Interoperability Team Blog http://blogss.msdn.com/interoperability